From 5c277639deefc00f921422729db22a5bea0473a1 Mon Sep 17 00:00:00 2001 From: auouymous Date: Tue, 8 Nov 2022 01:05:05 -0700 Subject: [PATCH] Check for size mismatch when syncing and send to device again. An interrupted sync results in a partial file on the device and syncing again would not finish sending the file. Ideally it could also compare checksums but that would slow down syncing. Fixes #1416. --- src/gpodder/sync.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gpodder/sync.py b/src/gpodder/sync.py index d75e859e..684470fc 100644 --- a/src/gpodder/sync.py +++ b/src/gpodder/sync.py @@ -530,7 +530,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()) -- 2.11.4.GIT