mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-24 12:49:38 +00:00
Add LibraryItemController test for delete/batchDelete/updateMedia endpoint functions to correctly remove authors & series with no books
This commit is contained in:
parent
c496db7c95
commit
2b5484243b
4 changed files with 210 additions and 5 deletions
|
|
@ -86,6 +86,7 @@ class CacheManager {
|
|||
}
|
||||
|
||||
async purgeEntityCache(entityId, cachePath) {
|
||||
if (!entityId || !cachePath) return []
|
||||
return Promise.all(
|
||||
(await fs.readdir(cachePath)).reduce((promises, file) => {
|
||||
if (file.startsWith(entityId)) {
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ class LibraryItem {
|
|||
* @returns {Promise<LibraryFile>} null if not saved
|
||||
*/
|
||||
async saveMetadata() {
|
||||
if (this.isSavingMetadata) return null
|
||||
if (this.isSavingMetadata || !global.MetadataPath) return null
|
||||
|
||||
this.isSavingMetadata = true
|
||||
|
||||
|
|
|
|||
|
|
@ -400,10 +400,12 @@ class ApiRouter {
|
|||
await CacheManager.purgeCoverCache(libraryItemId)
|
||||
|
||||
// Remove metadata file if in /metadata/items dir
|
||||
const itemMetadataPath = Path.join(global.MetadataPath, 'items', libraryItemId)
|
||||
if (await fs.pathExists(itemMetadataPath)) {
|
||||
Logger.info(`[ApiRouter] Removing item metadata at "${itemMetadataPath}"`)
|
||||
await fs.remove(itemMetadataPath)
|
||||
if (global.MetadataPath) {
|
||||
const itemMetadataPath = Path.join(global.MetadataPath, 'items', libraryItemId)
|
||||
if (await fs.pathExists(itemMetadataPath)) {
|
||||
Logger.info(`[ApiRouter] Removing item metadata at "${itemMetadataPath}"`)
|
||||
await fs.remove(itemMetadataPath)
|
||||
}
|
||||
}
|
||||
|
||||
await Database.libraryItemModel.removeById(libraryItemId)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue