| ... | @@ -14,6 +14,9 @@ | ... | @@ -14,6 +14,9 @@ |
| 14 | * | 14 | * |
| 15 | * @module usageScanCache | 15 | * @module usageScanCache |
| 16 | */ | 16 | */ |
| | 17 | // @effect-diagnostics nodeBuiltinImport:off |
| | 18 | import * as NodePath from "node:path"; |
| | 19 | |
| 17 | import type { UsageProviderKind } from "@t3tools/contracts"; | 20 | import type { UsageProviderKind } from "@t3tools/contracts"; |
| 18 | | 21 | |
| 19 | import type { UsageRecord } from "./usageTranscripts.ts"; | 22 | import type { UsageRecord } from "./usageTranscripts.ts"; |
| ... | @@ -229,7 +232,15 @@ export function pruneScanCache(cache: ScanCache, options: PruneOptions): number | ... | @@ -229,7 +232,15 @@ export function pruneScanCache(cache: ScanCache, options: PruneOptions): number |
| 229 | let removed = 0; | 232 | let removed = 0; |
| 230 | for (const [path, entry] of cache) { | 233 | for (const [path, entry] of cache) { |
| 231 | const agedOut = entry.mtimeMs < options.retentionCutoffMs; | 234 | const agedOut = entry.mtimeMs < options.retentionCutoffMs; |
| 232 | const underWalkedRoot = options.walkedRoots.some((root) => path.startsWith(root)); | 235 | const underWalkedRoot = options.walkedRoots.some((root) => { |
| | 236 | const relative = NodePath.relative(root, path); |
| | 237 | return ( |
| | 238 | relative === "" || |
| | 239 | (relative !== ".." && |
| | 240 | !relative.startsWith(`..${NodePath.sep}`) && |
| | 241 | !NodePath.isAbsolute(relative)) |
| | 242 | ); |
| | 243 | }); |
| 233 | const deleted = | 244 | const deleted = |
| 234 | underWalkedRoot && entry.mtimeMs >= options.windowStartMs && !options.livePaths.has(path); | 245 | underWalkedRoot && entry.mtimeMs >= options.windowStartMs && !options.livePaths.has(path); |
| 235 | if (agedOut || deleted) { | 246 | if (agedOut || deleted) { |