|
1 | | -import { createDedupeCache, resolveDedupeNonNegativeInteger } from "../infra/dedupe.js"; |
| 1 | +import { createDedupeCache } from "../infra/dedupe.js"; |
| 2 | +import { resolveNonNegativeIntegerOption } from "../infra/numeric-options.js"; |
2 | 3 | import type { FileLockOptions } from "./file-lock.js"; |
3 | 4 | import { withFileLock } from "./file-lock.js"; |
4 | 5 | import { readJsonFileWithFallback, writeJsonFileAtomically } from "./json-store.js"; |
@@ -148,9 +149,9 @@ function isRecentTimestamp(seenAt: number | undefined, ttlMs: number, now: numbe |
148 | 149 |
|
149 | 150 | /** Create a dedupe helper that combines in-memory fast checks with a lock-protected disk store. */ |
150 | 151 | export function createPersistentDedupe(options: PersistentDedupeOptions): PersistentDedupe { |
151 | | - const ttlMs = resolveDedupeNonNegativeInteger(options.ttlMs, 0); |
152 | | - const memoryMaxSize = resolveDedupeNonNegativeInteger(options.memoryMaxSize, 0); |
153 | | - const fileMaxEntries = Math.max(1, resolveDedupeNonNegativeInteger(options.fileMaxEntries, 1)); |
| 152 | + const ttlMs = resolveNonNegativeIntegerOption(options.ttlMs, 0); |
| 153 | + const memoryMaxSize = resolveNonNegativeIntegerOption(options.memoryMaxSize, 0); |
| 154 | + const fileMaxEntries = Math.max(1, resolveNonNegativeIntegerOption(options.fileMaxEntries, 1)); |
154 | 155 | const lockOptions = mergeLockOptions(options.lockOptions); |
155 | 156 | const memory = createDedupeCache({ ttlMs, maxSize: memoryMaxSize }); |
156 | 157 | const inflight = new Map<string, Promise<boolean>>(); |
@@ -324,15 +325,15 @@ function createReleasedClaimError(scopedKey: string): Error { |
324 | 325 |
|
325 | 326 | /** Create a claim/commit/release dedupe guard backed by memory and optional persistent storage. */ |
326 | 327 | export function createClaimableDedupe(options: ClaimableDedupeOptions): ClaimableDedupe { |
327 | | - const ttlMs = resolveDedupeNonNegativeInteger(options.ttlMs, 0); |
328 | | - const memoryMaxSize = resolveDedupeNonNegativeInteger(options.memoryMaxSize, 0); |
| 328 | + const ttlMs = resolveNonNegativeIntegerOption(options.ttlMs, 0); |
| 329 | + const memoryMaxSize = resolveNonNegativeIntegerOption(options.memoryMaxSize, 0); |
329 | 330 | const memory = createDedupeCache({ ttlMs, maxSize: memoryMaxSize }); |
330 | 331 | const persistent = |
331 | 332 | options.resolveFilePath != null |
332 | 333 | ? createPersistentDedupe({ |
333 | 334 | ttlMs, |
334 | 335 | memoryMaxSize, |
335 | | - fileMaxEntries: Math.max(1, resolveDedupeNonNegativeInteger(options.fileMaxEntries, 1)), |
| 336 | + fileMaxEntries: Math.max(1, resolveNonNegativeIntegerOption(options.fileMaxEntries, 1)), |
336 | 337 | resolveFilePath: options.resolveFilePath, |
337 | 338 | lockOptions: options.lockOptions, |
338 | 339 | onDiskError: options.onDiskError, |
|
0 commit comments