From caa0f104d48696703dfb43a5a9970662f14ca9cd Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Wed, 26 Sep 2018 16:00:37 -0700 Subject: [PATCH] Working on path re-creation Signed-off-by: James Ketrenos --- server/scanner.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/server/scanner.js b/server/scanner.js index 142325a..c8c1638 100755 --- a/server/scanner.js +++ b/server/scanner.js @@ -47,10 +47,13 @@ let processRunning = false; const { spawn } = require('child_process'); const sharp = require("sharp"), exif = require("exif-reader"); -const stat = function (path) { - if (path.indexOf(picturesPath) != 0) { - path = picturesPath + path; +const stat = function (_path) { + if (_path.indexOf(picturesPath.replace(/\/$/, "")) == 0) { + _path = _path.substring(picturesPath.length); } + + let path = picturesPath + _path; + return new Promise(function (resolve, reject) { fs.stat(path, function (error, stats) { if (error) { @@ -68,8 +71,7 @@ const mkdir = function (_path) { let parts = _path.split("/"), path; - console.log(parts, _path); - + parts.unshift(picturesPath); return Promise.mapSeries(parts, function (part) { if (!path) { @@ -77,6 +79,7 @@ const mkdir = function (_path) { } else { path += "/" + part; } + return stat(path).catch(function (error) { if (error.code != "ENOENT") { throw error; @@ -280,7 +283,7 @@ function processBlock(items) { asset.taken = asset.modified = date; } - let dst = picturesPath + path + "thumbs/" + file; + let dst = picturesPath + path + "thumbs/scaled/" + file; return exists(dst).then(function(exist) { if (exist) {