mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-09-11 20:31:55 +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
|
if (!item.isDownloadFinished || !finalizingItems.add(item.id)) return
|
||||||
IncompleteDownloadCleanup.cancel(context, item.id)
|
IncompleteDownloadCleanup.cancel(context, item.id)
|
||||||
scope.launch {
|
scope.launch {
|
||||||
|
try {
|
||||||
val scanLock = scanLocks.computeIfAbsent(scanDestinationKey(item)) { Any() }
|
val scanLock = scanLocks.computeIfAbsent(scanDestinationKey(item)) { Any() }
|
||||||
synchronized(scanLock) {
|
synchronized(scanLock) {
|
||||||
folderScanner.scanDownloadItem(item) { scanResult ->
|
folderScanner.scanDownloadItem(item) { scanResult ->
|
||||||
@@ -579,13 +580,20 @@ class DownloadItemManager(
|
|||||||
}
|
}
|
||||||
clientEventEmitter.onDownloadItemComplete(event)
|
clientEventEmitter.onDownloadItemComplete(event)
|
||||||
synchronized(this@DownloadItemManager) {
|
synchronized(this@DownloadItemManager) {
|
||||||
finalizingItems.remove(item.id)
|
|
||||||
downloadItemQueue.remove(item)
|
downloadItemQueue.remove(item)
|
||||||
DeviceManager.dbManager.removeDownloadItem(item.id)
|
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