mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-11-07 16:44:16 +01:00
Fix:Matching a library with no items not removing library scan #2118
This commit is contained in:
parent
b5a27226cc
commit
ae88a4d20a
@ -231,8 +231,12 @@ export default {
|
||||
scanComplete(data) {
|
||||
console.log('Scan complete received', data)
|
||||
|
||||
var message = `${data.type === 'match' ? 'Match' : 'Scan'} "${data.name}" complete!`
|
||||
if (data.results) {
|
||||
let message = `${data.type === 'match' ? 'Match' : 'Scan'} "${data.name}" complete!`
|
||||
let toastType = 'success'
|
||||
if (data.error) {
|
||||
message = `${data.type === 'match' ? 'Match' : 'Scan'} "${data.name}" finished with error:\n${data.error}`
|
||||
toastType = 'error'
|
||||
} else if (data.results) {
|
||||
var scanResultMsgs = []
|
||||
var results = data.results
|
||||
if (results.added) scanResultMsgs.push(`${results.added} added`)
|
||||
@ -247,9 +251,9 @@ export default {
|
||||
|
||||
var existingScan = this.$store.getters['scanners/getLibraryScan'](data.id)
|
||||
if (existingScan && !isNaN(existingScan.toastId)) {
|
||||
this.$toast.update(existingScan.toastId, { content: message, options: { timeout: 5000, type: 'success', closeButton: false, onClose: () => null } }, true)
|
||||
this.$toast.update(existingScan.toastId, { content: message, options: { timeout: 5000, type: toastType, closeButton: false, onClose: () => null } }, true)
|
||||
} else {
|
||||
this.$toast.success(message, { timeout: 5000 })
|
||||
this.$toast[toastType](message, { timeout: 5000 })
|
||||
}
|
||||
|
||||
this.$store.commit('scanners/remove', data)
|
||||
|
@ -19,6 +19,7 @@ class LibraryScan {
|
||||
this.startedAt = null
|
||||
this.finishedAt = null
|
||||
this.elapsed = null
|
||||
this.error = null
|
||||
|
||||
this.resultsMissing = 0
|
||||
this.resultsAdded = 0
|
||||
@ -52,6 +53,7 @@ class LibraryScan {
|
||||
id: this.libraryId,
|
||||
type: this.type,
|
||||
name: this.libraryName,
|
||||
error: this.error,
|
||||
results: {
|
||||
added: this.resultsAdded,
|
||||
updated: this.resultsUpdated,
|
||||
@ -74,6 +76,7 @@ class LibraryScan {
|
||||
startedAt: this.startedAt,
|
||||
finishedAt: this.finishedAt,
|
||||
elapsed: this.elapsed,
|
||||
error: this.error,
|
||||
resultsAdded: this.resultsAdded,
|
||||
resultsUpdated: this.resultsUpdated,
|
||||
resultsMissing: this.resultsMissing
|
||||
@ -88,9 +91,14 @@ class LibraryScan {
|
||||
this.startedAt = Date.now()
|
||||
}
|
||||
|
||||
setComplete() {
|
||||
/**
|
||||
*
|
||||
* @param {string} error
|
||||
*/
|
||||
setComplete(error = null) {
|
||||
this.finishedAt = Date.now()
|
||||
this.elapsed = this.finishedAt - this.startedAt
|
||||
this.error = error
|
||||
}
|
||||
|
||||
getLogLevelString(level) {
|
||||
|
@ -328,7 +328,7 @@ class Scanner {
|
||||
let offset = 0
|
||||
|
||||
const libraryScan = new LibraryScan()
|
||||
libraryScan.setData(library, null, 'match')
|
||||
libraryScan.setData(library, 'match')
|
||||
LibraryScanner.librariesScanning.push(libraryScan.getScanEmitData)
|
||||
SocketAuthority.emitter('scan_start', libraryScan.getScanEmitData)
|
||||
|
||||
@ -338,10 +338,9 @@ class Scanner {
|
||||
while (hasMoreChunks) {
|
||||
const libraryItems = await Database.libraryItemModel.getLibraryItemsIncrement(offset, limit, { libraryId: library.id })
|
||||
if (!libraryItems.length) {
|
||||
Logger.error(`[Scanner] matchLibraryItems: Library has no items ${library.id}`)
|
||||
SocketAuthority.emitter('scan_complete', libraryScan.getScanEmitData)
|
||||
return
|
||||
break
|
||||
}
|
||||
|
||||
offset += limit
|
||||
hasMoreChunks = libraryItems.length < limit
|
||||
let oldLibraryItems = libraryItems.map(li => Database.libraryItemModel.getOldLibraryItem(li))
|
||||
@ -352,6 +351,13 @@ class Scanner {
|
||||
}
|
||||
}
|
||||
|
||||
if (offset === 0) {
|
||||
Logger.error(`[Scanner] matchLibraryItems: Library has no items ${library.id}`)
|
||||
libraryScan.setComplete('Library has no items')
|
||||
} else {
|
||||
libraryScan.setComplete()
|
||||
}
|
||||
|
||||
delete LibraryScanner.cancelLibraryScan[libraryScan.libraryId]
|
||||
LibraryScanner.librariesScanning = LibraryScanner.librariesScanning.filter(ls => ls.id !== library.id)
|
||||
SocketAuthority.emitter('scan_complete', libraryScan.getScanEmitData)
|
||||
|
Loading…
Reference in New Issue
Block a user