mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-26 16:48:53 +01:00
Fix:Server crash when updating cover to a directory #2007
This commit is contained in:
parent
4585d2816b
commit
75276f5a44
@ -283,9 +283,8 @@ export default {
|
||||
}
|
||||
if (success) {
|
||||
this.$toast.success('Update Successful')
|
||||
// this.$emit('close')
|
||||
} else {
|
||||
this.imageUrl = this.media.coverPath || ''
|
||||
} else if (this.media.coverPath) {
|
||||
this.imageUrl = this.media.coverPath
|
||||
}
|
||||
this.isProcessing = false
|
||||
},
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -59,6 +59,20 @@ async function getFileSize(path) {
|
||||
}
|
||||
module.exports.getFileSize = getFileSize
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} filepath
|
||||
* @returns {boolean}
|
||||
*/
|
||||
async function checkPathIsFile(filepath) {
|
||||
try {
|
||||
const stat = await fs.stat(filepath)
|
||||
return stat.isFile()
|
||||
} catch (err) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
module.exports.checkPathIsFile = checkPathIsFile
|
||||
|
||||
function getIno(path) {
|
||||
return fs.stat(path, { bigint: true }).then((data => String(data.ino))).catch((err) => {
|
||||
|
Loading…
Reference in New Issue
Block a user