mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-26 00:29:53 +01:00
Fix purge metadata/items paths
This commit is contained in:
parent
eb5331d34a
commit
8cff68ca64
@ -251,15 +251,19 @@ class Server {
|
|||||||
|
|
||||||
let purged = 0
|
let purged = 0
|
||||||
await Promise.all(foldersInItemsMetadata.map(async foldername => {
|
await Promise.all(foldersInItemsMetadata.map(async foldername => {
|
||||||
const hasMatchingItem = Database.libraryItems.find(ab => ab.id === foldername)
|
const itemFullPath = fileUtils.filePathToPOSIX(Path.join(itemsMetadata, foldername))
|
||||||
if (!hasMatchingItem) {
|
|
||||||
const folderPath = Path.join(itemsMetadata, foldername)
|
|
||||||
Logger.debug(`[Server] Purging unused metadata ${folderPath}`)
|
|
||||||
|
|
||||||
await fs.remove(folderPath).then(() => {
|
const hasMatchingItem = Database.libraryItems.find(li => {
|
||||||
|
if (!li.media.coverPath) return false
|
||||||
|
return itemFullPath === fileUtils.filePathToPOSIX(Path.dirname(li.media.coverPath))
|
||||||
|
})
|
||||||
|
if (!hasMatchingItem) {
|
||||||
|
Logger.debug(`[Server] Purging unused metadata ${itemFullPath}`)
|
||||||
|
|
||||||
|
await fs.remove(itemFullPath).then(() => {
|
||||||
purged++
|
purged++
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
Logger.error(`[Server] Failed to delete folder path ${folderPath}`, err)
|
Logger.error(`[Server] Failed to delete folder path ${itemFullPath}`, err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
Loading…
Reference in New Issue
Block a user