mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-09-12 04:41:45 +02:00
Add try catch around scan download item
This commit is contained in:
@@ -563,6 +563,7 @@ class DownloadItemManager(
|
||||
if (!item.isDownloadFinished || !finalizingItems.add(item.id)) return
|
||||
IncompleteDownloadCleanup.cancel(context, item.id)
|
||||
scope.launch {
|
||||
try {
|
||||
val scanLock = scanLocks.computeIfAbsent(scanDestinationKey(item)) { Any() }
|
||||
synchronized(scanLock) {
|
||||
folderScanner.scanDownloadItem(item) { scanResult ->
|
||||
@@ -579,13 +580,20 @@ class DownloadItemManager(
|
||||
}
|
||||
clientEventEmitter.onDownloadItemComplete(event)
|
||||
synchronized(this@DownloadItemManager) {
|
||||
finalizingItems.remove(item.id)
|
||||
downloadItemQueue.remove(item)
|
||||
DeviceManager.dbManager.removeDownloadItem(item.id)
|
||||
notifyQueueChanged()
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
// The files are already in place, so leave the item queued for restoreQueue to rescan.
|
||||
AbsLogger.error(tag, "Could not finalize download item ${item.id}: ${e.message}")
|
||||
} finally {
|
||||
synchronized(this@DownloadItemManager) {
|
||||
finalizingItems.remove(item.id)
|
||||
notifyQueueChanged()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user