From 2f1b3e6dac14e26af7f2f184198d497990aef7a4 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 21 Jan 2025 07:32:44 -0400 Subject: upd8: write preload file sizes cache This isn't viable yet because it includes full on-device path names - not good for sharing between devices (or privacy!). But the gist of writing and integration into the queue is here. --- src/upd8.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/upd8.js') diff --git a/src/upd8.js b/src/upd8.js index 306715dd..b9e71784 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -2614,6 +2614,38 @@ async function main() { memory: process.memoryUsage(), }); } + + // TODO: kinda jank that this is out of band of any particular step, + // even though it's operationally a follow-up to preloadFileSizes + + let oopsCache = false; + saveFileSizeCache: { + let cache; + try { + cache = fileSizePreloader.saveAsCache(); + } catch (error) { + console.error(error); + logWarn`Couldn't compute file size preloader's cache.`; + oopsCache = true; + break saveFileSizeCache; + } + + const cacheFile = path.join(mediaCachePath, 'file-size-cache.json'); + + try { + await writeFile(cacheFile, stringifyCache(cache)); + } catch (error) { + console.error(error); + logWarn`Couldn't save preloaded file sizes to a cache file:`; + logWarn`${cacheFile}`; + oopsCache = true; + } + } + + if (oopsCache) { + logWarn`This won't affect the build, but this build should not be used`; + logWarn`as a model for another build accessing its media files online.`; + } } if (stepStatusSummary.buildSearchIndex.status === STATUS_NOT_STARTED) { -- cgit 1.3.0-6-gf8a5