Fix:Server crash when updating cover to a directory #2007

This commit is contained in:
advplyr 2023-08-30 18:05:52 -05:00
parent 4585d2816b
commit 75276f5a44
3 changed files with 28 additions and 5 deletions

View file

@ -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) => {