bugfix: Ensure when media download completes and item update event is posted, the feed media has been updated,
This commit is contained in:
parent
9469ebc6c3
commit
71de4607a3
|
@ -151,8 +151,8 @@ public class PlaybackServiceTaskManagerTest {
|
|||
item.getMedia().setDownloaded(true);
|
||||
item.getMedia().setFile_url("file://123");
|
||||
item.setAutoDownload(false);
|
||||
DBWriter.setFeedItem(item).get();
|
||||
DBWriter.setFeedMedia(item.getMedia()).get();
|
||||
DBWriter.setFeedItem(item).get();
|
||||
}
|
||||
|
||||
// an approximation to ensure the item update event has been posted and processed.
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue