Merge pull request #1434 from auouymous/resync-on-file-size-change

Check for size mismatch when syncing and send to device again.
This commit is contained in:
auouymous 2022-11-18 10:50:25 +00:00 committed by GitHub
commit d64c06fa92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions

View File

@ -525,7 +525,17 @@ class MP3PlayerDevice(Device):
util.make_directory(folder)
if not to_file.query_exists():
to_file_exists = to_file.query_exists()
from_size = episode.file_size
to_size = episode.file_size
if to_file_exists:
try:
info = to_file.query_info(Gio.FILE_ATTRIBUTE_STANDARD_SIZE, Gio.FileQueryInfoFlags.NONE)
to_size = info.get_attribute_uint64(Gio.FILE_ATTRIBUTE_STANDARD_SIZE)
except GLib.Error:
# Assume same size and don't sync again
pass
if not to_file_exists or from_size != to_size:
logger.info('Copying %s => %s',
os.path.basename(from_file),
to_file.get_uri())