diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-01-21 07:32:44 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-01-21 07:32:44 -0400 |
commit | 2f1b3e6dac14e26af7f2f184198d497990aef7a4 (patch) | |
tree | e00f0ecf528369f93ad408f75be94b58d28b14e0 /src/upd8.js | |
parent | 35b3b4f4876804fed9542d8d04e93425a96e1fa1 (diff) |
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.
Diffstat (limited to 'src/upd8.js')
-rwxr-xr-x | src/upd8.js | 32 |
1 files changed, 32 insertions, 0 deletions
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) { |