@dench.com/cli 2.9.7 → 2.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -0
- package/fs-daemon +14 -1
- package/fs-daemon-health.ts +37 -0
- package/fs-daemon-pull-queue.ts +49 -0
- package/fs-daemon-pull.ts +111 -0
- package/fs-daemon-sync-tracker.ts +159 -0
- package/fs-daemon-workspace.ts +442 -0
- package/fs-daemon.ts +294 -536
- package/fs-workspace-worker.mjs +7 -0
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -250,6 +250,46 @@ Outreach needs a workspace member's credentials (a `dench signin` session, a
|
|
|
250
250
|
member-bound `DENCH_API_KEY`, or an agent session); an organization-only key
|
|
251
251
|
is refused.
|
|
252
252
|
|
|
253
|
+
## Workspace sync
|
|
254
|
+
|
|
255
|
+
Starting with CLI 2.9.8, `dench fs status` reports cached local daemon
|
|
256
|
+
health, not a live comparison between disk and Convex. The status probe
|
|
257
|
+
does not scan the workspace, contact Convex, or start a mount worker.
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
dench fs status --json
|
|
261
|
+
dench fs status --workspace /workspace --json
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
| JSON field | Meaning |
|
|
265
|
+
| --- | --- |
|
|
266
|
+
| `daemon.healthy` | The process is alive and cached progress passes freshness checks, with a short startup grace before the first scan. |
|
|
267
|
+
| `daemon.workspaceMatches` | The cached daemon serves the requested workspace root. A mismatch also makes `healthy` false. |
|
|
268
|
+
| `daemon.state.mountWorker` | Cached worker state, PID, last progress time, restart count, and error. |
|
|
269
|
+
| `counts.onDisk` | Last successful scan's count, only for the matching root; `null` when unavailable. Not a fresh count. |
|
|
270
|
+
| `counts.inConvex`, `counts.onlyOnDisk`, `counts.onlyInConvex`, `counts.hashMismatches` | `null`: these counts are unknown, not zero. |
|
|
271
|
+
| `driftStatus`, `drift` | `"not_checked"` and `[]`; an empty list does not prove that files match. |
|
|
272
|
+
|
|
273
|
+
Status exits **1** when the daemon is missing, dead, stale, stalled, or
|
|
274
|
+
serves a different root, including with `--json`; exit **0** means cached
|
|
275
|
+
health passed, not that every pending write has synced. The legacy
|
|
276
|
+
`--no-hash` and `--drift-limit N` flags remain accepted but have no effect.
|
|
277
|
+
|
|
278
|
+
To pull a workspace file through the running daemon:
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
dench fs pull "/reports/example.csv" --wait --timeout-ms 10000 --json
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
`--timeout-ms` covers the whole request, including queueing, metadata,
|
|
285
|
+
download, and mounted write (default 10 seconds, capped at 60 seconds).
|
|
286
|
+
Successful `--wait` means the downloaded original passed its SHA-256 check
|
|
287
|
+
and the write finished before the deadline. Without `--wait`, success
|
|
288
|
+
means only that the request was queued.
|
|
289
|
+
|
|
290
|
+
See the [daemon isolation and rollout notes](../docs/agent-notes/sandbox-execution.md#workspace-sync-daemon-cli-298)
|
|
291
|
+
for recovery limits and why an existing process does not hot-upgrade.
|
|
292
|
+
|
|
253
293
|
## Sandbox / API key auth (no `dench signin` required)
|
|
254
294
|
|
|
255
295
|
Inside a Daytona sandbox the unified Dench API key is baked into envVars
|
package/fs-daemon
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { isAbsolute, resolve } from "node:path";
|
|
3
|
+
|
|
4
|
+
// tsx probes cwd/tsconfig even with tsconfig:false in its scoped-import API.
|
|
5
|
+
// Preserve explicit relative roots, then keep loader/runtime startup off FUSE.
|
|
6
|
+
for (let i = 2; i < process.argv.length - 1; i++) {
|
|
7
|
+
if (["--workspace", "--hot-cache"].includes(process.argv[i]) && !isAbsolute(process.argv[i + 1])) {
|
|
8
|
+
process.argv[i + 1] = resolve(process.argv[i + 1]);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
for (const name of ["DENCH_VOLUME_PATH", "DENCH_HOT_CACHE_PATH"]) {
|
|
12
|
+
if (process.env[name] && !isAbsolute(process.env[name])) process.env[name] = resolve(process.env[name]);
|
|
13
|
+
}
|
|
14
|
+
process.chdir("/tmp");
|
|
2
15
|
|
|
3
16
|
const entrypoint = new URL("./fs-daemon.ts", import.meta.url).href;
|
|
4
17
|
|
|
@@ -6,5 +19,5 @@ if (process.versions.bun) {
|
|
|
6
19
|
await import(entrypoint);
|
|
7
20
|
} else {
|
|
8
21
|
const { tsImport } = await import("tsx/esm/api");
|
|
9
|
-
await tsImport(entrypoint, import.meta.url);
|
|
22
|
+
await tsImport(entrypoint, { parentURL: import.meta.url, tsconfig: false });
|
|
10
23
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
|
|
3
|
+
export function cachedWorkspaceMatches(
|
|
4
|
+
cached: unknown,
|
|
5
|
+
requested: string,
|
|
6
|
+
): boolean {
|
|
7
|
+
// Lexical only. realpath/stat would send the health probe back onto FUSE.
|
|
8
|
+
return typeof cached === "string" && resolve(cached) === resolve(requested);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Health probes use cached local state only: never touch the mounted tree. */
|
|
12
|
+
export function isDaemonHealthy(
|
|
13
|
+
state: {
|
|
14
|
+
startedAt: number;
|
|
15
|
+
lastUpdatedAt: number;
|
|
16
|
+
lastReconcile: { finishedAt: number } | null;
|
|
17
|
+
mountWorker?: { state: string; lastProgressAt: number | null };
|
|
18
|
+
} | null,
|
|
19
|
+
pidAlive: boolean,
|
|
20
|
+
now = Date.now(),
|
|
21
|
+
): boolean {
|
|
22
|
+
const fresh = (timestamp: number | null | undefined, maxAge: number) =>
|
|
23
|
+
typeof timestamp === "number" &&
|
|
24
|
+
Number.isFinite(timestamp) &&
|
|
25
|
+
now - timestamp >= 0 &&
|
|
26
|
+
now - timestamp < maxAge;
|
|
27
|
+
return Boolean(
|
|
28
|
+
pidAlive &&
|
|
29
|
+
state &&
|
|
30
|
+
fresh(state.lastUpdatedAt, 15_000) &&
|
|
31
|
+
state.mountWorker?.state === "ready" &&
|
|
32
|
+
fresh(state.mountWorker.lastProgressAt, 45_000) &&
|
|
33
|
+
(state.lastReconcile
|
|
34
|
+
? fresh(state.lastReconcile.finishedAt, 60_000)
|
|
35
|
+
: fresh(state.startedAt, 10_000)),
|
|
36
|
+
);
|
|
37
|
+
}
|
package/fs-daemon-pull-queue.ts
CHANGED
|
@@ -33,3 +33,52 @@ export function createPullQueueDrain(args: {
|
|
|
33
33
|
return inFlight;
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
type RemoteFile = { path: string; contentHash?: string; isDir: boolean };
|
|
38
|
+
|
|
39
|
+
/** Retain the latest subscription snapshot across worker/network failures.
|
|
40
|
+
* Only one drain runs at a time; retry is triggered by recovery or a heartbeat. */
|
|
41
|
+
export function createRemoteFileQueue(args: {
|
|
42
|
+
isReady: () => boolean;
|
|
43
|
+
getHash: (path: string) => string | undefined;
|
|
44
|
+
pull: (
|
|
45
|
+
row: RemoteFile & { contentHash: string },
|
|
46
|
+
shouldPublish: () => boolean,
|
|
47
|
+
) => Promise<void>;
|
|
48
|
+
onError: (error: unknown, path?: string) => void;
|
|
49
|
+
}): {
|
|
50
|
+
update: (rows: RemoteFile[]) => Promise<void>;
|
|
51
|
+
retry: () => Promise<void>;
|
|
52
|
+
} {
|
|
53
|
+
let latest = new Map<string, RemoteFile & { contentHash: string }>();
|
|
54
|
+
const drain = createPullQueueDrain({
|
|
55
|
+
processRequests: async () => {
|
|
56
|
+
for (const row of latest.values()) {
|
|
57
|
+
if (!args.isReady()) return;
|
|
58
|
+
const shouldPublish = () =>
|
|
59
|
+
latest.get(row.path)?.contentHash === row.contentHash;
|
|
60
|
+
if (!shouldPublish() || args.getHash(row.path) === row.contentHash)
|
|
61
|
+
continue;
|
|
62
|
+
try {
|
|
63
|
+
await args.pull(row, shouldPublish);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
args.onError(error, row.path);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
onError: (error) => args.onError(error),
|
|
70
|
+
});
|
|
71
|
+
return {
|
|
72
|
+
update: (rows) => {
|
|
73
|
+
latest = new Map(
|
|
74
|
+
rows.flatMap((row) =>
|
|
75
|
+
!row.isDir && row.contentHash
|
|
76
|
+
? [[row.path, { ...row, contentHash: row.contentHash }] as const]
|
|
77
|
+
: [],
|
|
78
|
+
),
|
|
79
|
+
);
|
|
80
|
+
return drain();
|
|
81
|
+
},
|
|
82
|
+
retry: drain,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
export type PullRequest = {
|
|
4
|
+
id: string;
|
|
5
|
+
paths: string[];
|
|
6
|
+
requestedAt: number;
|
|
7
|
+
deadlineAt?: number;
|
|
8
|
+
};
|
|
9
|
+
export function parsePullRequest(
|
|
10
|
+
value: unknown,
|
|
11
|
+
fileName: string,
|
|
12
|
+
): PullRequest {
|
|
13
|
+
const item = value as Partial<PullRequest> | null;
|
|
14
|
+
if (
|
|
15
|
+
!item ||
|
|
16
|
+
typeof item.id !== "string" ||
|
|
17
|
+
!/^[a-zA-Z0-9-]+$/.test(item.id) ||
|
|
18
|
+
fileName !== `request-${item.id}.json` ||
|
|
19
|
+
!Array.isArray(item.paths) ||
|
|
20
|
+
!item.paths.length ||
|
|
21
|
+
item.paths.length > 1000 ||
|
|
22
|
+
item.paths.some(
|
|
23
|
+
(path) => typeof path !== "string" || !path || path.length > 4096,
|
|
24
|
+
) ||
|
|
25
|
+
typeof item.requestedAt !== "number" ||
|
|
26
|
+
!Number.isFinite(item.requestedAt) ||
|
|
27
|
+
(item.deadlineAt !== undefined &&
|
|
28
|
+
(typeof item.deadlineAt !== "number" ||
|
|
29
|
+
!Number.isFinite(item.deadlineAt)))
|
|
30
|
+
) {
|
|
31
|
+
throw new Error("pull_invalid_request");
|
|
32
|
+
}
|
|
33
|
+
return item as PullRequest;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function pullTimeRemaining(deadline: number): number {
|
|
37
|
+
const remaining = deadline - Date.now();
|
|
38
|
+
if (remaining <= 0) throw new Error("pull_timeout");
|
|
39
|
+
return remaining;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function withinPullDeadline<T>(
|
|
43
|
+
operation: (signal: AbortSignal) => Promise<T>,
|
|
44
|
+
deadline: number,
|
|
45
|
+
): Promise<T> {
|
|
46
|
+
const remaining = pullTimeRemaining(deadline);
|
|
47
|
+
const controller = new AbortController();
|
|
48
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
49
|
+
try {
|
|
50
|
+
return await Promise.race([
|
|
51
|
+
operation(controller.signal),
|
|
52
|
+
new Promise<never>((_, reject) => {
|
|
53
|
+
timer = setTimeout(() => {
|
|
54
|
+
controller.abort();
|
|
55
|
+
reject(new Error("pull_timeout"));
|
|
56
|
+
}, remaining);
|
|
57
|
+
}),
|
|
58
|
+
]);
|
|
59
|
+
} finally {
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** A successful pull means verified ORIGINAL bytes finished writing, not just
|
|
65
|
+
* a fileTree row or a URL existed. No signed URLs/vendor bodies in errors. */
|
|
66
|
+
export async function downloadRemoteFile(args: {
|
|
67
|
+
resolveUrl: () => Promise<string | null>;
|
|
68
|
+
expectedHash: string;
|
|
69
|
+
deadline: number;
|
|
70
|
+
maxBytes?: number;
|
|
71
|
+
}): Promise<Uint8Array> {
|
|
72
|
+
const url = await withinPullDeadline(args.resolveUrl, args.deadline);
|
|
73
|
+
if (!url) throw new Error("pull_original_missing");
|
|
74
|
+
return withinPullDeadline(async (signal) => {
|
|
75
|
+
try {
|
|
76
|
+
const response = await fetch(url, { signal });
|
|
77
|
+
if (!response.ok) {
|
|
78
|
+
void response.body?.cancel().catch(() => undefined);
|
|
79
|
+
throw new Error("pull_http_error: " + response.status);
|
|
80
|
+
}
|
|
81
|
+
if (!response.body) throw new Error("pull_empty_body");
|
|
82
|
+
const reader = response.body.getReader();
|
|
83
|
+
const chunks: Uint8Array[] = [];
|
|
84
|
+
let size = 0;
|
|
85
|
+
const hash = createHash("sha256");
|
|
86
|
+
try {
|
|
87
|
+
for (;;) {
|
|
88
|
+
const { done, value } = await reader.read();
|
|
89
|
+
signal.throwIfAborted();
|
|
90
|
+
if (done) break;
|
|
91
|
+
size += value.length;
|
|
92
|
+
if (size > (args.maxBytes ?? 512 * 1024 * 1024)) {
|
|
93
|
+
void reader.cancel().catch(() => undefined);
|
|
94
|
+
throw new Error("pull_too_large");
|
|
95
|
+
}
|
|
96
|
+
hash.update(value);
|
|
97
|
+
chunks.push(value);
|
|
98
|
+
}
|
|
99
|
+
} finally {
|
|
100
|
+
reader.releaseLock();
|
|
101
|
+
}
|
|
102
|
+
if (hash.digest("hex") !== args.expectedHash)
|
|
103
|
+
throw new Error("pull_hash_mismatch");
|
|
104
|
+
return Buffer.concat(chunks, size);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
if (error instanceof Error && error.message.startsWith("pull_"))
|
|
107
|
+
throw error;
|
|
108
|
+
throw new Error(signal.aborted ? "pull_timeout" : "pull_fetch_failed");
|
|
109
|
+
}
|
|
110
|
+
}, args.deadline);
|
|
111
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { DrainStatus } from "./fs-daemon-flush";
|
|
2
|
+
const CIRCUIT_BREAKER_LIMIT = 5;
|
|
3
|
+
const CIRCUIT_BREAKER_WINDOW_MS = 10_000;
|
|
4
|
+
const CIRCUIT_BREAKER_PAUSE_MS = 60_000;
|
|
5
|
+
|
|
6
|
+
export type BreakerState = {
|
|
7
|
+
path: string;
|
|
8
|
+
trippedAt: number;
|
|
9
|
+
resumesAt: number;
|
|
10
|
+
syncsInWindow: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// `DrainStatus` lives in cli/fs-daemon-flush.ts so the flush subcommand's
|
|
14
|
+
// polling helper can import it without dragging in the daemon's main
|
|
15
|
+
// entrypoint (which would crash test runners that import this file).
|
|
16
|
+
|
|
17
|
+
export class HashTracker {
|
|
18
|
+
private hashes = new Map<string, string>();
|
|
19
|
+
private timers = new Map<string, NodeJS.Timeout>();
|
|
20
|
+
private recentSyncs = new Map<string, number[]>();
|
|
21
|
+
private paused = new Map<string, BreakerState>();
|
|
22
|
+
private onBreakerTrip?: (state: BreakerState) => void;
|
|
23
|
+
// Bumped right before each scheduled fn() actually starts; decremented
|
|
24
|
+
// in the fn()'s `.finally()`. The flush subcommand reads this through
|
|
25
|
+
// `drainStatus()` (mirrored into the status file once per reconcile).
|
|
26
|
+
private inFlightUploads = 0;
|
|
27
|
+
private inFlightPaths = new Set<string>();
|
|
28
|
+
private failedPaths = new Set<string>();
|
|
29
|
+
private generations = new Map<string, number>();
|
|
30
|
+
needsRetry(path: string): boolean {
|
|
31
|
+
return this.failedPaths.has(path);
|
|
32
|
+
}
|
|
33
|
+
retryPaths(): string[] {
|
|
34
|
+
return [...this.failedPaths];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get(absPath: string): string | undefined {
|
|
38
|
+
return this.hashes.get(absPath);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
set(absPath: string, hash: string): void {
|
|
42
|
+
this.hashes.set(absPath, hash);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
forget(absPath: string): void {
|
|
46
|
+
this.generations.set(absPath, (this.generations.get(absPath) ?? 0) + 1);
|
|
47
|
+
this.hashes.delete(absPath);
|
|
48
|
+
this.failedPaths.delete(absPath);
|
|
49
|
+
const timer = this.timers.get(absPath);
|
|
50
|
+
if (timer) {
|
|
51
|
+
clearTimeout(timer);
|
|
52
|
+
this.timers.delete(absPath);
|
|
53
|
+
}
|
|
54
|
+
this.recentSyncs.delete(absPath);
|
|
55
|
+
this.paused.delete(absPath);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
knownPaths(): string[] {
|
|
59
|
+
return [...this.hashes.keys()];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
activeBreakers(): BreakerState[] {
|
|
63
|
+
return [...this.paused.values()];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
setBreakerListener(listener: (state: BreakerState) => void): void {
|
|
67
|
+
this.onBreakerTrip = listener;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Returns true if the path is currently throttled by the circuit
|
|
72
|
+
* breaker (>5 syncs in the last 10s).
|
|
73
|
+
*/
|
|
74
|
+
recordAndCheckBreaker(absPath: string): boolean {
|
|
75
|
+
if (this.paused.has(absPath)) return true;
|
|
76
|
+
const now = Date.now();
|
|
77
|
+
const recent = (this.recentSyncs.get(absPath) ?? []).filter(
|
|
78
|
+
(ts) => now - ts < CIRCUIT_BREAKER_WINDOW_MS,
|
|
79
|
+
);
|
|
80
|
+
recent.push(now);
|
|
81
|
+
this.recentSyncs.set(absPath, recent);
|
|
82
|
+
if (recent.length > CIRCUIT_BREAKER_LIMIT) {
|
|
83
|
+
const state: BreakerState = {
|
|
84
|
+
path: absPath,
|
|
85
|
+
trippedAt: now,
|
|
86
|
+
resumesAt: now + CIRCUIT_BREAKER_PAUSE_MS,
|
|
87
|
+
syncsInWindow: recent.length,
|
|
88
|
+
};
|
|
89
|
+
this.paused.set(absPath, state);
|
|
90
|
+
// Loud enough to land in the supervisor's tail of fs-daemon.log
|
|
91
|
+
// (sandbox-bootstrap.ts surfaces the last 50 lines on failure).
|
|
92
|
+
console.error(
|
|
93
|
+
`[dench-fs-daemon] CIRCUIT_BREAKER tripped path=${absPath} syncs=${recent.length} pause=${CIRCUIT_BREAKER_PAUSE_MS}ms`,
|
|
94
|
+
);
|
|
95
|
+
this.onBreakerTrip?.(state);
|
|
96
|
+
setTimeout(() => {
|
|
97
|
+
this.paused.delete(absPath);
|
|
98
|
+
this.recentSyncs.delete(absPath);
|
|
99
|
+
console.warn(
|
|
100
|
+
`[dench-fs-daemon] circuit breaker released for ${absPath}`,
|
|
101
|
+
);
|
|
102
|
+
}, CIRCUIT_BREAKER_PAUSE_MS);
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
schedule(absPath: string, ms: number, fn: () => Promise<void>): void {
|
|
109
|
+
const existing = this.timers.get(absPath);
|
|
110
|
+
if (existing) clearTimeout(existing);
|
|
111
|
+
const timer = setTimeout(() => {
|
|
112
|
+
this.timers.delete(absPath);
|
|
113
|
+
// Bound mounted reads and network uploads together; one path is serial.
|
|
114
|
+
if (this.inFlightUploads >= 4 || this.inFlightPaths.has(absPath)) {
|
|
115
|
+
this.schedule(absPath, 50, fn);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
this.inFlightPaths.add(absPath);
|
|
119
|
+
const generation = this.generations.get(absPath) ?? 0;
|
|
120
|
+
// Track this work in-flight so `flush` knows to wait for the
|
|
121
|
+
// upload to actually finish, not just for the next reconcile
|
|
122
|
+
// tick to fire. The decrement runs in `finally` so even a
|
|
123
|
+
// throwing upload doesn't strand the counter at non-zero.
|
|
124
|
+
this.inFlightUploads += 1;
|
|
125
|
+
Promise.resolve()
|
|
126
|
+
.then(fn)
|
|
127
|
+
.then(() => {
|
|
128
|
+
if ((this.generations.get(absPath) ?? 0) === generation)
|
|
129
|
+
this.failedPaths.delete(absPath);
|
|
130
|
+
})
|
|
131
|
+
.catch((error) => {
|
|
132
|
+
if ((this.generations.get(absPath) ?? 0) === generation)
|
|
133
|
+
this.failedPaths.add(absPath);
|
|
134
|
+
console.error(
|
|
135
|
+
`[dench-fs-daemon] sync failed for ${absPath}: ${
|
|
136
|
+
error instanceof Error ? error.message : String(error)
|
|
137
|
+
}`,
|
|
138
|
+
);
|
|
139
|
+
})
|
|
140
|
+
.finally(() => {
|
|
141
|
+
this.inFlightPaths.delete(absPath);
|
|
142
|
+
this.inFlightUploads = Math.max(0, this.inFlightUploads - 1);
|
|
143
|
+
});
|
|
144
|
+
}, ms);
|
|
145
|
+
this.timers.set(absPath, timer);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Snapshot of pending sync work. Mirrored into the daemon status
|
|
150
|
+
* file once per reconcile tick so `dench-fs-daemon flush` can wait
|
|
151
|
+
* on it without an IPC channel.
|
|
152
|
+
*/
|
|
153
|
+
drainStatus(): DrainStatus {
|
|
154
|
+
return {
|
|
155
|
+
pendingPaths: new Set([...this.timers.keys(), ...this.failedPaths]).size,
|
|
156
|
+
inFlightUploads: this.inFlightUploads,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|