mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
Handle library scan failure gracefully
This commit is contained in:
parent
5b09bd8242
commit
1099dbe642
@ -79,6 +79,7 @@ class LibraryScanner {
|
||||
|
||||
Logger.info(`[LibraryScanner] Starting${forceRescan ? ' (forced)' : ''} library scan ${libraryScan.id} for ${libraryScan.libraryName}`)
|
||||
|
||||
try {
|
||||
const canceled = await this.scanLibrary(libraryScan, forceRescan)
|
||||
|
||||
if (canceled) {
|
||||
@ -89,7 +90,6 @@ class LibraryScanner {
|
||||
libraryScan.setComplete()
|
||||
|
||||
Logger.info(`[LibraryScanner] Library scan ${libraryScan.id} completed in ${libraryScan.elapsedTimestamp} | ${libraryScan.resultStats}`)
|
||||
this.librariesScanning = this.librariesScanning.filter((ls) => ls.id !== library.id)
|
||||
|
||||
if (canceled && !libraryScan.totalResults) {
|
||||
task.setFinished('Scan canceled')
|
||||
@ -111,6 +111,17 @@ class LibraryScanner {
|
||||
await library.save()
|
||||
|
||||
task.setFinished(libraryScan.scanResultsString)
|
||||
} catch (err) {
|
||||
libraryScan.setComplete(err)
|
||||
Logger.error(`[LibraryScanner] Library scan ${libraryScan.id} failed after ${libraryScan.elapsedTimestamp}.`, err)
|
||||
|
||||
if (this.cancelLibraryScan[libraryScan.libraryId]) delete this.cancelLibraryScan[libraryScan.libraryId]
|
||||
|
||||
task.setFailed(`Scan failed: ${err.message}`)
|
||||
}
|
||||
|
||||
this.librariesScanning = this.librariesScanning.filter((ls) => ls.id !== library.id)
|
||||
|
||||
TaskManager.taskFinished(task)
|
||||
|
||||
if (libraryScan.totalResults) {
|
||||
|
Loading…
Reference in New Issue
Block a user