mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-15 08:19:37 +00:00
Fix:Server crash when updating cover to a directory #2007
This commit is contained in:
parent
4585d2816b
commit
75276f5a44
3 changed files with 28 additions and 5 deletions
|
|
@ -6,7 +6,7 @@ const imageType = require('../libs/imageType')
|
|||
const filePerms = require('../utils/filePerms')
|
||||
|
||||
const globals = require('../utils/globals')
|
||||
const { downloadFile, filePathToPOSIX } = require('../utils/fileUtils')
|
||||
const { downloadFile, filePathToPOSIX, checkPathIsFile } = require('../utils/fileUtils')
|
||||
const { extractCoverArt } = require('../utils/ffmpegHelpers')
|
||||
|
||||
class CoverManager {
|
||||
|
|
@ -180,6 +180,7 @@ class CoverManager {
|
|||
updated: false
|
||||
}
|
||||
}
|
||||
|
||||
// Cover path does not exist
|
||||
if (!await fs.pathExists(coverPath)) {
|
||||
Logger.error(`[CoverManager] validate cover path does not exist "${coverPath}"`)
|
||||
|
|
@ -187,8 +188,17 @@ class CoverManager {
|
|||
error: 'Cover path does not exist'
|
||||
}
|
||||
}
|
||||
|
||||
// Cover path is not a file
|
||||
if (!await checkPathIsFile(coverPath)) {
|
||||
Logger.error(`[CoverManager] validate cover path is not a file "${coverPath}"`)
|
||||
return {
|
||||
error: 'Cover path is not a file'
|
||||
}
|
||||
}
|
||||
|
||||
// Check valid image at path
|
||||
var imgtype = await this.checkFileIsValidImage(coverPath, true)
|
||||
var imgtype = await this.checkFileIsValidImage(coverPath, false)
|
||||
if (imgtype.error) {
|
||||
return imgtype
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue