mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-08 00:08:14 +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) {
|
if (success) {
|
||||||
this.$toast.success('Update Successful')
|
this.$toast.success('Update Successful')
|
||||||
// this.$emit('close')
|
} else if (this.media.coverPath) {
|
||||||
} else {
|
this.imageUrl = this.media.coverPath
|
||||||
this.imageUrl = this.media.coverPath || ''
|
|
||||||
}
|
}
|
||||||
this.isProcessing = false
|
this.isProcessing = false
|
||||||
},
|
},
|
||||||
|
@ -6,7 +6,7 @@ const imageType = require('../libs/imageType')
|
|||||||
const filePerms = require('../utils/filePerms')
|
const filePerms = require('../utils/filePerms')
|
||||||
|
|
||||||
const globals = require('../utils/globals')
|
const globals = require('../utils/globals')
|
||||||
const { downloadFile, filePathToPOSIX } = require('../utils/fileUtils')
|
const { downloadFile, filePathToPOSIX, checkPathIsFile } = require('../utils/fileUtils')
|
||||||
const { extractCoverArt } = require('../utils/ffmpegHelpers')
|
const { extractCoverArt } = require('../utils/ffmpegHelpers')
|
||||||
|
|
||||||
class CoverManager {
|
class CoverManager {
|
||||||
@ -180,6 +180,7 @@ class CoverManager {
|
|||||||
updated: false
|
updated: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cover path does not exist
|
// Cover path does not exist
|
||||||
if (!await fs.pathExists(coverPath)) {
|
if (!await fs.pathExists(coverPath)) {
|
||||||
Logger.error(`[CoverManager] validate cover path does not exist "${coverPath}"`)
|
Logger.error(`[CoverManager] validate cover path does not exist "${coverPath}"`)
|
||||||
@ -187,8 +188,17 @@ class CoverManager {
|
|||||||
error: 'Cover path does not exist'
|
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
|
// Check valid image at path
|
||||||
var imgtype = await this.checkFileIsValidImage(coverPath, true)
|
var imgtype = await this.checkFileIsValidImage(coverPath, false)
|
||||||
if (imgtype.error) {
|
if (imgtype.error) {
|
||||||
return imgtype
|
return imgtype
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,20 @@ async function getFileSize(path) {
|
|||||||
}
|
}
|
||||||
module.exports.getFileSize = getFileSize
|
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) {
|
function getIno(path) {
|
||||||
return fs.stat(path, { bigint: true }).then((data => String(data.ino))).catch((err) => {
|
return fs.stat(path, { bigint: true }).then((data => String(data.ino))).catch((err) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user