From 872b6cb91cc8fec06435329c669a7e95bfd57733 Mon Sep 17 00:00:00 2001 From: Thomas Perl Date: Tue, 12 May 2009 10:14:20 +0200 Subject: [PATCH] Filter tracks before synchronization (bug 446) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This makes the sync dialog show the correct count of episodes that will be transferred to the device when there are files that are not going to be synced. Thanks to Götz Waschk for reporting this bug. --- src/gpodder/sync.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/gpodder/sync.py b/src/gpodder/sync.py index 7b91e62a..c68dcadf 100644 --- a/src/gpodder/sync.py +++ b/src/gpodder/sync.py @@ -182,6 +182,17 @@ class Device(services.ObservableService): return True def add_tracks(self, tracklist=[], force_played=False): + for track in list(tracklist): + # Filter tracks that are not meant to be synchronized + does_not_exist = not track.was_downloaded(and_exists=True) + exclude_played = track.is_played and not force_played and \ + gl.config.only_sync_not_played + wrong_type = track.file_type() not in self.allowed_types + + if does_not_exist or exclude_played or wrong_type: + log('Excluding %s from sync', track.title, sender=self) + tracklist.remove(track) + compare_episodes = lambda a, b: cmp(a.pubDate, b.pubDate) for id, track in enumerate(sorted(tracklist, cmp=compare_episodes)): if self.cancelled: @@ -189,15 +200,6 @@ class Device(services.ObservableService): self.notify('progress', id+1, len(tracklist)) - if not track.was_downloaded(and_exists=True): - continue - - if track.is_played and gl.config.only_sync_not_played and not force_played: - continue - - if track.file_type() not in self.allowed_types: - continue - added = self.add_track(track) if gl.config.on_sync_mark_played: -- 2.11.4.GIT