From 71de4607a35c0164f91687cabc81b62abd1df51c Mon Sep 17 00:00:00 2001 From: orionlee Date: Sun, 29 Sep 2019 12:55:02 -0700 Subject: bugfix: Ensure when media download completes and item update event is posted, the feed media has been updated, --- .../danoeh/antennapod/core/service/download/DownloadService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'core/src/main/java/de') diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java index ce61bff68..4b6416384 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java @@ -997,14 +997,17 @@ public class DownloadService extends Service { final FeedItem item = media.getItem(); try { + DBWriter.setFeedMedia(media).get(); + // we've received the media, we don't want to autodownload it again if (item != null) { item.setAutoDownload(false); + // setFeedItem() signals (via EventBus) that the item has been updated, + // so we do it after the enclosing media has been updated above, + // to ensure subscribers will get the updated FeedMedia as well DBWriter.setFeedItem(item).get(); } - DBWriter.setFeedMedia(media).get(); - if (item != null && UserPreferences.enqueueDownloadedEpisodes() && !DBTasks.isInQueue(DownloadService.this, item.getId())) { DBWriter.addQueueItem(DownloadService.this, item).get(); -- cgit v1.2.3