From 1a92f5e8198e5d1a56d0d9f7272f731f4e98bfce Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 29 Oct 2023 15:27:11 -0300 Subject: upd8: integrate --migrate-thumbs option --- src/upd8.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/upd8.js b/src/upd8.js index 0c52dc0..a504275 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -64,6 +64,7 @@ import genThumbs, { defaultMagickThreads, determineMediaCachePath, isThumb, + migrateThumbsIntoDedicatedCacheDirectory, verifyImagePaths, } from '#thumbs'; @@ -116,6 +117,9 @@ async function main() { loadThumbnailCache: {...defaultStepStatus, name: `load thumbnail cache file`}, + migrateThumbnails: + {...defaultStepStatus, name: `migrate thumbnails`}, + generateThumbnails: {...defaultStepStatus, name: `generate thumbnails`}, @@ -260,6 +264,11 @@ async function main() { type: 'flag', }, + 'migrate-thumbs': { + help: `Transfer automatically generated thumbnail files out of an existing media directory and into the easier-to-manage media-cache directory`, + type: 'flag', + }, + // Just working on data entries and not interested in actually // generating site HTML yet? This flag will cut execution off right // 8efore any site 8uilding actually happens. @@ -429,6 +438,7 @@ async function main() { const mediaPath = cliOptions['media-path'] || process.env.HSMUSIC_MEDIA; const langPath = cliOptions['lang-path'] || process.env.HSMUSIC_LANG; // Can 8e left unset! + const migrateThumbs = cliOptions['migrate-thumbs'] ?? false; const skipThumbs = cliOptions['skip-thumbs'] ?? false; const thumbsOnly = cliOptions['thumbs-only'] ?? false; const noBuild = cliOptions['no-build'] ?? false; @@ -505,6 +515,35 @@ async function main() { logInfo`Using media cache at: ${mediaCachePath} (${mediaCachePathAnnotation})`; + if (migrateThumbs) { + stepStatusSummary.migrateThumbnails.status = STATUS_STARTED_NOT_DONE; + + const result = await migrateThumbsIntoDedicatedCacheDirectory({ + mediaPath, + mediaCachePath, + queueSize, + }); + + if (result.succses) { + Object.assign(stepStatusSummary.migrateThumbnails, { + status: STATUS_FATAL_ERROR, + annotation: `view log for details`, + }); + return false; + } + + stepStatusSummary.migrateThumbnails.status = STATUS_DONE_CLEAN; + + logInfo`Good to go! Run hsmusic again without ${'--migrate-thumbs'} to start`; + logInfo`using the migrated media cache.`; + return true; + } else { + Object.assign(stepStatusSummary.migrateThumbnails, { + status: STATUS_NOT_APPLICABLE, + annotation: `--migrate-thumbs not provided`, + }); + } + const niceShowAggregate = (error, ...opts) => { showAggregate(error, { showTraces: showAggregateTraces, -- cgit 1.3.0-6-gf8a5