Fix orphan check at startup

merge-requests/367/merge
Moe 2022-08-12 22:03:08 -07:00
parent a02313ba77
commit a45118c977
2 changed files with 9 additions and 6 deletions

View File

@ -57,12 +57,15 @@ module.exports = function(s,config){
splitted[1] = user + ':' + pass + '@' + splitted[1] splitted[1] = user + ':' + pass + '@' + splitted[1]
return splitted.join('://') return splitted.join('://')
} }
s.checkCorrectPathEnding = function(x){ s.checkCorrectPathEnding = function(x,reverse){
var length=x.length var newString = `${x}`
if(x.charAt(length-1)!=='/'){ var length = x.length
x=x+'/' if(reverse && x.charAt(length-1) === '/'){
newString = x.slice(0, -1)
}else if(x.charAt(length-1) !== '/'){
newString = x + '/'
} }
return x.replace('__DIR__',s.mainDirectory) return newString.replace('__DIR__',s.mainDirectory)
} }
s.mergeDeep = function(...objects) { s.mergeDeep = function(...objects) {
const isObject = obj => obj && typeof obj === 'object'; const isObject = obj => obj && typeof obj === 'object';

View File

@ -62,7 +62,7 @@ module.exports = (s,config,lang) => {
// const findCmd = [videosDirectory].concat(options.flags || ['-maxdepth','1']) // const findCmd = [videosDirectory].concat(options.flags || ['-maxdepth','1'])
fs.writeFileSync( fs.writeFileSync(
tempDirectory + 'orphanCheck.sh', tempDirectory + 'orphanCheck.sh',
`find "${videosDirectory}" -maxdepth 1 -type f -exec stat -c "%n" {} + | sort -r | head -n ${options.checkMax}` `find "${s.checkCorrectPathEnding(videosDirectory,true)}" -maxdepth 1 -type f -exec stat -c "%n" {} + | sort -r | head -n ${options.checkMax}`
); );
let listing = spawn('sh',[tempDirectory + 'orphanCheck.sh']) let listing = spawn('sh',[tempDirectory + 'orphanCheck.sh'])
// const onData = options.onData ? options.onData : () => {} // const onData = options.onData ? options.onData : () => {}