mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-31 23:57:15 +02:00
Fixes missing LocalMediaProgress for downloads without existing progress
This commit is contained in:
@@ -186,12 +186,15 @@ public class AbsDownloader: CAPPlugin, URLSessionDownloadDelegate {
|
|||||||
|
|
||||||
statusNotification["localLibraryItem"] = try? localLibraryItem.asDictionary()
|
statusNotification["localLibraryItem"] = try? localLibraryItem.asDictionary()
|
||||||
|
|
||||||
|
var localMediaProgress: LocalMediaProgress
|
||||||
if let progress = libraryItem.userMediaProgress {
|
if let progress = libraryItem.userMediaProgress {
|
||||||
let episode = downloadItem.media?.episodes.first(where: { $0.id == downloadItem.episodeId })
|
let episode = downloadItem.media?.episodes.first(where: { $0.id == downloadItem.episodeId })
|
||||||
let localMediaProgress = LocalMediaProgress(localLibraryItem: localLibraryItem!, episode: episode, progress: progress)
|
localMediaProgress = LocalMediaProgress(localLibraryItem: localLibraryItem!, episode: episode, progress: progress)
|
||||||
Database.shared.saveLocalMediaProgress(localMediaProgress)
|
} else {
|
||||||
statusNotification["localMediaProgress"] = try? localMediaProgress.asDictionary()
|
localMediaProgress = LocalMediaProgress.fetchOrCreateLocalMediaProgress(localMediaProgressId: nil, localLibraryItemId: localLibraryItem?.id, localEpisodeId: downloadItem.episodeId)!
|
||||||
}
|
}
|
||||||
|
Database.shared.saveLocalMediaProgress(localMediaProgress)
|
||||||
|
statusNotification["localMediaProgress"] = try? localMediaProgress.asDictionary()
|
||||||
|
|
||||||
self.notifyListeners("onItemDownloadComplete", data: statusNotification)
|
self.notifyListeners("onItemDownloadComplete", data: statusNotification)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user