Revisión | 0c8bf157617a2c4f485de269c2d0b731f06dfcd9 (tree) |
---|---|
Tiempo | 2018-01-15 07:05:47 |
Autor | Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fast...> |
Commiter | Jaime Marquínez Ferrándiz |
Sync song if the file is older that the current version in the library
@@ -152,3 +152,14 @@ | ||
152 | 152 | copy_path = copy_path.decode() |
153 | 153 | if not db.execute('SELECT * FROM song WHERE idSong=?', (item_id,)).fetchall(): |
154 | 154 | db.execute('INSERT INTO song (idSong, filename) VALUES (?,?)', (item_id, copy_path)) |
155 | + else: | |
156 | + # check if the file is outdated | |
157 | + try: | |
158 | + date = datetime.datetime.fromtimestamp(item.current_mtime()) | |
159 | + result = db.execute('SELECT * FROM song where idSong=? and synced=1 and date < ?', (item_id, date)).fetchone() | |
160 | + except FileNotFoundError as ex: | |
161 | + pass | |
162 | + else: | |
163 | + if result: | |
164 | + self.info('There\'s a newer file for "{}"', item) | |
165 | + db.execute('UPDATE song SET synced=0,date=NULL WHERE idSong=?', (item_id,)) |