From 94e6d8a68d24b6f512360e4ab46438178d62e318 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 16 Aug 2023 09:50:20 -0300 Subject: thumbs: traverse with wiki-matching posix style when verifying paths --- src/gen-thumbs.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/gen-thumbs.js') diff --git a/src/gen-thumbs.js b/src/gen-thumbs.js index dfa2c2ab..655ab6d0 100644 --- a/src/gen-thumbs.js +++ b/src/gen-thumbs.js @@ -208,6 +208,7 @@ export async function clearThumbs(mediaPath, { logInfo`Looking for thumbnails to clear out...`; const thumbFiles = await traverse(mediaPath, { + pathStyle: 'device', filterFile: file => isThumb(file), filterDir: name => name !== '.git', }); @@ -512,15 +513,33 @@ export async function verifyImagePaths(mediaPath, {urls, wikiData}) { // Recursively traverses the provided (extant) media path, filtering so only // "source" images are returned - no thumbnails and no non-images. Provide // target as 'generate' or 'verify' to indicate the desired use of the results. -// Under 'verify', all source files are returned, so that their existence can -// be verified against a list of expected source files. Under 'generate', files -// which shouldn't actually get thumbnails are excluded. +// +// Under 'verify': +// +// * All source files are returned, so that their existence can be verified +// against a list of expected source files. +// +// * Source files are returned in "wiki" path style, AKA with POSIX-style +// forward slashes, regardless the system being run on. +// +// Under 'generate': +// +// * All files which shouldn't actually have thumbnails generated are excluded. +// +// * Source files are returned in device-style, with backslashes on Windows. +// These are suitable to be passed as command-line arguments to ImageMagick. +// +// Both modes return paths relative to mediaPath, with no ./ or .\ at the +// front. +// export async function traverseSourceImagePaths(mediaPath, {target}) { if (target !== 'verify' && target !== 'generate') { throw new Error(`Expected target to be 'verify' or 'generate', got ${target}`); } return await traverse(mediaPath, { + pathStyle: (target === 'verify' ? 'posix' : 'device'), + filterFile(name) { const ext = path.extname(name); -- cgit 1.3.0-6-gf8a5