Skip to content

Commit

Permalink
Device sync: Fix sync when playlists are disabled (bug 1769)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnwickremasinghe authored and thp committed Feb 20, 2013
1 parent 93668b6 commit b7d2374
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
15 changes: 10 additions & 5 deletions src/gpodder/gtkui/desktop/sync.py
Expand Up @@ -178,7 +178,7 @@ def resume_sync(episode_urls, channel_urls,progress):
self.commit_changes_to_database()
for current_channel in self.channels:
#only sync those channels marked for syncing
if current_channel.sync_to_mp3_player:
if (current_channel.sync_to_mp3_player and self._config.device_sync.playlists.create):

#get playlist object
playlist=gPodderDevicePlaylist(self._config,
Expand All @@ -191,10 +191,11 @@ def resume_sync(episode_urls, channel_urls,progress):

#enable updating of UI
self.enable_download_list_update()

title = _('Update successful')
message = _('The playlist on your MP3 player has been updated.')
self.notification(message, title, widget=self.preferences_widget)

if self._config.device_sync.playlists.create:
title = _('Update successful')
message = _('The playlist on your MP3 player has been updated.')
self.notification(message, title, widget=self.preferences_widget)

# Finally start the synchronization process
@util.run_in_background
Expand Down Expand Up @@ -280,6 +281,10 @@ def auto_delete_callback(episodes):
title = _('Error writing playlist files')
message = _(str(ioe))
self.notification(message, title, widget=self.preferences_widget)
else:
logger.info ('Not creating playlists - starting sync')
resume_sync([],[],None)



# This function is used to remove files from the device
Expand Down
27 changes: 15 additions & 12 deletions src/gpodder/sync.py
Expand Up @@ -213,18 +213,21 @@ def add_sync_tasks(self,tracklist, force_played=False):
if does_not_exist or exclude_played or wrong_type:
logger.info('Excluding %s from sync', track.title)
tracklist.remove(track)

for track in sorted(tracklist, key=lambda e: e.pubdate_prop):
if self.cancelled:
return False

# XXX: need to check if track is added properly?
sync_task=SyncTask(track)

sync_task.status=sync_task.QUEUED
sync_task.device=self
self.download_status_model.register_task(sync_task)
self.download_queue_manager.add_task(sync_task)

if tracklist:
for track in sorted(tracklist, key=lambda e: e.pubdate_prop):
if self.cancelled:
return False

# XXX: need to check if track is added properly?
sync_task=SyncTask(track)

sync_task.status=sync_task.QUEUED
sync_task.device=self
self.download_status_model.register_task(sync_task)
self.download_queue_manager.add_task(sync_task)
else:
logger.warning("No episodes to sync")

return True

Expand Down

0 comments on commit b7d2374

Please sign in to comment.