fix(server): preserve usage cache outside walked roots (#8540)
Co-authored-by: Simone <[email protected]>
This commit is contained in:
1 parent
f47e74004a
commit
6d15c5bbc3
2 files changed
+26
-1
No files matched your search
@@ -14,6 +14,9 @@
|
||||
*
|
||||
* @module usageScanCache
|
||||
*/
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
import * as NodePath from "node:path";
|
||||
|
||||
import type { UsageProviderKind } from "@t3tools/contracts";
|
||||
|
||||
import type { UsageRecord } from "./usageTranscripts.ts";
|
||||
@@ -229,7 +232,15 @@ export function pruneScanCache(cache: ScanCache, options: PruneOptions): number
|
||||
let removed = 0;
|
||||
for (const [path, entry] of cache) {
|
||||
const agedOut = entry.mtimeMs < options.retentionCutoffMs;
|
||||
const underWalkedRoot = options.walkedRoots.some((root) => path.startsWith(root));
|
||||
const underWalkedRoot = options.walkedRoots.some((root) => {
|
||||
const relative = NodePath.relative(root, path);
|
||||
return (
|
||||
relative === "" ||
|
||||
(relative !== ".." &&
|
||||
!relative.startsWith(`..${NodePath.sep}`) &&
|
||||
!NodePath.isAbsolute(relative))
|
||||
);
|
||||
});
|
||||
const deleted =
|
||||
underWalkedRoot && entry.mtimeMs >= options.windowStartMs && !options.livePaths.has(path);
|
||||
if (agedOut || deleted) {
|
||||
|
||||
Reference in new issue
Block a user