|
|
@@ -127,6 +127,12 @@ const processOutput = str => {
|
|
|
process.stdout.write(str);
|
|
|
};
|
|
|
|
|
|
+const getFilesize = async file => {
|
|
|
+ let stats = fs.statSync(file);
|
|
|
+ let bytes = stats['size'];
|
|
|
+ return (bytes) ? bytes/1024 : 0;
|
|
|
+};
|
|
|
+
|
|
|
// spawn a handbrake
|
|
|
const processWithHandbrake = (input, output, preset) => {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
@@ -183,10 +189,9 @@ const processFile = async file => {
|
|
|
let found = findFile(db, file); // does it already exist?
|
|
|
if (found && found.status && found.status === 'success') {
|
|
|
// was it already processed?
|
|
|
- //console.log(`File ${file} has already been successfully processed.`);
|
|
|
return false; // break this loop
|
|
|
} else if (!found) {
|
|
|
- // was it found?
|
|
|
+ // was it found? .. nope
|
|
|
processOutput(` -> ${path.basename(file)} [processing]`);
|
|
|
setFile(db, {
|
|
|
input: file,
|
|
|
@@ -231,8 +236,9 @@ const processFile = async file => {
|
|
|
// baseline the target
|
|
|
let target = destination + (folder ? '/' + folder : ''); // setup the target location
|
|
|
output = target + '/' + output + '.' + ext; // update the new name
|
|
|
- // do we already have an existing output that matches?
|
|
|
- if (fs.existsSync(output)) {
|
|
|
+ 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,
|
|
|
@@ -357,7 +363,6 @@ const main = async () => {
|
|
|
watcher
|
|
|
.on('add', async file => {
|
|
|
// when a file is added ...
|
|
|
- console.log(` -> ${file} has been added`);
|
|
|
queue.push(file); // push the file onto the queue to be processed
|
|
|
})
|
|
|
.on('change', file => {
|