mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-25 16:18:54 +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
|
||||
await Promise.all(foldersInItemsMetadata.map(async foldername => {
|
||||
const hasMatchingItem = Database.libraryItems.find(ab => ab.id === foldername)
|
||||
if (!hasMatchingItem) {
|
||||
const folderPath = Path.join(itemsMetadata, foldername)
|
||||
Logger.debug(`[Server] Purging unused metadata ${folderPath}`)
|
||||
const itemFullPath = fileUtils.filePathToPOSIX(Path.join(itemsMetadata, foldername))
|
||||
|
||||
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++
|
||||
}).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