Commit 29ea02c
committed
refactor: DRY delta-upgrade, async patch-cache, fix shared-file cleanup
delta-upgrade.ts:
- Extract resolveAndApplyDelta() to unify cache-first + apply logic
for both stable and nightly channels
- Extract resolveNightlyChainWithContext() to share GHCR setup between
resolveNightlyDelta and prefetchNightlyPatches
- Extract prefetchAndCache() to unify both prefetch functions
- Add steps field to PatchChain and StableChainInfo so chain resolution
directly provides version step pairs (eliminates redundant
filterAndSortChainTags call in nightly prefetch)
- Remove buildNightlySteps() (now done inside resolveNightlyChain)
- Net reduction: 55 lines
patch-cache.ts:
- Make ensureCacheDir() async via node:fs/promises mkdir
- Parallelize patch writes in savePatchesToCache via Promise.all
- Parallelize chain meta reads in loadAllChainMetas via Promise.all
- Parallelize patch file reads in loadCachedChain via Promise.all
- Replace file.exists() checks with ENOENT handling (avoids TOCTOU)
- Make cleanup fully async with unlink from node:fs/promises
- Merge classifyChains + removeExpiredChains into single
removeExpiredEntries with parallel deletes
- Replace all sync fs imports with async equivalents
tests:
- Add steps assertions for extractStableChain, resolveStableChain,
and resolveNightlyChain
- Add test for shared patch file preservation during cleanup
(validates the BugBot-reported fix)1 parent 349207d commit 29ea02c
File tree
4 files changed
+369
-272
lines changed- src/lib
- test/lib
4 files changed
+369
-272
lines changed
0 commit comments