« get me outta code hell

util: remove findFiles util, adapt traverse - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/gen-thumbs.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-08-19 11:51:13 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-08-19 12:24:03 -0300
commit9e4a20224a2cc005775cb99b5ea888c253e48e3a (patch)
tree7757c2b5a269657a760a076fd25e724457c4941b /src/gen-thumbs.js
parent3b601adf3945a487f4aa07eb8c0f62161460345a (diff)
util: remove findFiles util, adapt traverse
Diffstat (limited to 'src/gen-thumbs.js')
-rw-r--r--src/gen-thumbs.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/gen-thumbs.js b/src/gen-thumbs.js
index 655ab6d..2d432e4 100644
--- a/src/gen-thumbs.js
+++ b/src/gen-thumbs.js
@@ -220,6 +220,7 @@ export async function clearThumbs(mediaPath, {
     const unsafeFiles = thumbFiles.filter(file => {
       if (path.extname(file) !== '.jpg') return true;
       if (thumbtacks.every(tack => !file.includes(tack))) return true;
+      if (path.relative(mediaPath, file).startsWith('../')) return true;
       return false;
     });
 
@@ -240,7 +241,7 @@ export async function clearThumbs(mediaPath, {
     await progressPromiseAll(`Removing thumbnail files`, queue(
       thumbFiles.map(file => async () => {
         try {
-          await unlink(path.join(mediaPath, file));
+          await unlink(file);
         } catch (error) {
           if (error.code !== 'ENOENT') {
             errored.push(file);
@@ -539,6 +540,7 @@ export async function traverseSourceImagePaths(mediaPath, {target}) {
 
   return await traverse(mediaPath, {
     pathStyle: (target === 'verify' ? 'posix' : 'device'),
+    prefixPath: '',
 
     filterFile(name) {
       const ext = path.extname(name);