|
|
@@ -128,9 +128,9 @@ const processOutput = str => {
|
|
|
};
|
|
|
|
|
|
const getFilesize = async file => {
|
|
|
- let stats = fs.statSync(file);
|
|
|
- let bytes = stats['size'];
|
|
|
- return (bytes) ? bytes/1024 : 0;
|
|
|
+ let stats = fs.existsSync(file) ? fs.statSync(file) : false;
|
|
|
+ let bytes = (stats) ? stats['size'] : 0;
|
|
|
+ return (bytes && bytes > 0) ? bytes/1024 : 0;
|
|
|
};
|
|
|
|
|
|
// spawn a handbrake
|
|
|
@@ -236,19 +236,20 @@ const processFile = async file => {
|
|
|
// baseline the target
|
|
|
let target = destination + (folder ? '/' + folder : ''); // setup the target location
|
|
|
output = target + '/' + output + '.' + ext; // update the new name
|
|
|
- let outputSize = await getFilesize(output);
|
|
|
- // do we already have an existing output that matches? ... make sure its bigger than 100k
|
|
|
- if (fs.existsSync(output) && outputSize > 100) {
|
|
|
- processOutput(` -> ${path.basename(file)} [skipping ... already processed]\n`);
|
|
|
- setFile(db, file, {
|
|
|
- output: output,
|
|
|
- status: 'success',
|
|
|
- date: new Date(),
|
|
|
- }); // update database with status
|
|
|
- return false;
|
|
|
- } else {
|
|
|
- process.stdout.write('\n'); // send a new line
|
|
|
+ // do we already have an existing output that matches?
|
|
|
+ if (fs.existsSync(output)) {
|
|
|
+ let outputSize = await getFilesize(output); //get output filesize
|
|
|
+ if (outputSize > 100) { //make sure its bigger than 100k
|
|
|
+ processOutput(` -> ${path.basename(file)} [skipping ... already processed]\n`);
|
|
|
+ setFile(db, file, {
|
|
|
+ output: output,
|
|
|
+ status: 'success',
|
|
|
+ date: new Date(),
|
|
|
+ }); // update database with status
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
+ process.stdout.write('\n'); // send a new line
|
|
|
// update database with output name
|
|
|
setFile(db, file, {
|
|
|
output: output,
|