@1agh/maude 2.0.4 → 2.0.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/apps/hub/src/project-transactions/kernel.mjs +10 -1
- package/apps/studio/access/closure.ts +156 -16
- package/apps/studio/access/filters.ts +39 -5
- package/apps/studio/access/known-canvases.ts +24 -1
- package/apps/studio/access/refused-inputs.ts +89 -0
- package/apps/studio/actions/agents.ts +59 -0
- package/apps/studio/actions/ctx.ts +3 -0
- package/apps/studio/actions/defs/app.ts +12 -0
- package/apps/studio/actions/defs/sync.ts +13 -0
- package/apps/studio/actions/defs/view.ts +59 -3
- package/apps/studio/actions/keymap.gen.ts +35 -0
- package/apps/studio/actions/menu.ts +2 -0
- package/apps/studio/actions/types.ts +3 -1
- package/apps/studio/actions.manifest.json +148 -1
- package/apps/studio/actions.parity.json +31 -1
- package/apps/studio/annotations/ui/ai-seen.tsx +4 -3
- package/apps/studio/annotations/ui/element-node.tsx +139 -54
- package/apps/studio/annotations/ui/lod.tsx +1 -1
- package/apps/studio/annotations/ui/ride.ts +2 -1
- package/apps/studio/annotations/ui/text-style.ts +1 -1
- package/apps/studio/annotations-context-toolbar.tsx +5 -4
- package/apps/studio/annotations-layer.tsx +4 -15
- package/apps/studio/api.ts +425 -128
- package/apps/studio/artboard-activity-overlay.tsx +4 -4
- package/apps/studio/artboard-ai-copies.tsx +4 -4
- package/apps/studio/artboard-freeze.ts +108 -0
- package/apps/studio/artboard-live-gate.tsx +636 -0
- package/apps/studio/artboard-live.ts +831 -0
- package/apps/studio/artboard-placeholder.ts +197 -0
- package/apps/studio/artboard-still-raster.ts +485 -0
- package/apps/studio/artboard-still-warmup.ts +221 -0
- package/apps/studio/artboard-still.ts +1188 -0
- package/apps/studio/artboard-webgl.ts +669 -0
- package/apps/studio/asset-placeholder.tsx +237 -132
- package/apps/studio/asset-upload-bars.tsx +4 -4
- package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
- package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
- package/apps/studio/bin/_canvas-reasons.mjs +34 -0
- package/apps/studio/bin/_ds-check-live.mjs +37 -0
- package/apps/studio/bin/_ds-check.mjs +4 -1
- package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
- package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
- package/apps/studio/bin/_import-asset.mjs +2 -1
- package/apps/studio/bin/_perf-probe-open.mjs +364 -0
- package/apps/studio/bin/_perf-probe.mjs +2 -1
- package/apps/studio/bin/_perf-shared.mjs +12 -7
- package/apps/studio/bin/_pw-launch.mjs +26 -1
- package/apps/studio/bin/_studio-verb.mjs +24 -3
- package/apps/studio/bin/_thumb-blank.mjs +70 -0
- package/apps/studio/bin/_thumb-cover.mjs +35 -0
- package/apps/studio/bin/_thumbs-playwright.mjs +89 -12
- package/apps/studio/bin/ds-check.sh +5 -1
- package/apps/studio/bin/perf.sh +30 -1
- package/apps/studio/bin/server-up.sh +7 -2
- package/apps/studio/bin/smoke.sh +19 -0
- package/apps/studio/bridge/dgn-protocol.ts +35 -0
- package/apps/studio/canvas-build-sandbox.ts +69 -13
- package/apps/studio/canvas-camera.ts +90 -0
- package/apps/studio/canvas-comment-mount.tsx +9 -9
- package/apps/studio/canvas-lib.tsx +289 -44
- package/apps/studio/canvas-pages-view.tsx +465 -0
- package/apps/studio/canvas-pages.ts +305 -0
- package/apps/studio/canvas-rows.ts +62 -0
- package/apps/studio/canvas-shell.tsx +62 -16
- package/apps/studio/canvas-theme-icons.tsx +41 -0
- package/apps/studio/canvas-theme-pill.tsx +15 -6
- package/apps/studio/canvas-theme.ts +12 -11
- package/apps/studio/client/app.jsx +7 -0
- package/apps/studio/client/canvas-url.js +36 -1
- package/apps/studio/client/home/HomeAccounts.jsx +262 -0
- package/apps/studio/client/home/Shelves.jsx +4 -3
- package/apps/studio/client/home/home-accounts-model.js +121 -0
- package/apps/studio/client/home/home-api.js +6 -0
- package/apps/studio/client/home/home-app.jsx +141 -40
- package/apps/studio/client/home/home-model.js +172 -6
- package/apps/studio/client/home/home.css +169 -5
- package/apps/studio/client/home/shell-mode.js +8 -1
- package/apps/studio/client/hooks/canvas-origin-probe.js +34 -0
- package/apps/studio/client/hooks/use-action-keys.jsx +3 -1
- package/apps/studio/client/hooks/use-canvas-bridge.jsx +1 -1
- package/apps/studio/client/hooks/use-palette-and-panels.jsx +23 -6
- package/apps/studio/client/hooks/use-photo-and-timeline.jsx +16 -8
- package/apps/studio/client/hooks/use-project-data.jsx +13 -2
- package/apps/studio/client/hooks/use-shell-core.jsx +19 -9
- package/apps/studio/client/index-loader.ts +41 -21
- package/apps/studio/client/inspector/inspector-panel.jsx +35 -14
- package/apps/studio/client/panels/ChatPanel.jsx +27 -20
- package/apps/studio/client/panels/CreateProject.jsx +19 -5
- package/apps/studio/client/panels/caps-cache.js +46 -0
- package/apps/studio/client/shell/viewport.jsx +66 -22
- package/apps/studio/client/tree/tree.jsx +17 -0
- package/apps/studio/client/v2/access/access-client.js +2 -0
- package/apps/studio/client/v2/access/access-host.jsx +12 -1
- package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
- package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
- package/apps/studio/client/v2/ai/Composer.jsx +27 -10
- package/apps/studio/client/v2/canvases/canvases-panel.jsx +24 -0
- package/apps/studio/client/v2/canvases/use-canvas-index.js +24 -1
- package/apps/studio/client/v2/code/canvas-error-card.jsx +14 -2
- package/apps/studio/client/v2/code/canvas-imports-card.jsx +19 -14
- package/apps/studio/client/v2/code/canvas-imports-words.js +60 -0
- package/apps/studio/client/v2/code/canvas-waiting-card.jsx +59 -5
- package/apps/studio/client/v2/code/canvas-waiting.js +18 -1
- package/apps/studio/client/v2/code/code-bus.js +5 -0
- package/apps/studio/client/v2/code/code-consent-sheet.jsx +87 -0
- package/apps/studio/client/v2/code/code-consent.js +67 -0
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +62 -10
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +314 -5
- package/apps/studio/client/v2/ds/advanced-host.jsx +11 -26
- package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
- package/apps/studio/client/v2/ds/library-host.jsx +45 -45
- package/apps/studio/client/v2/ds/make-host.jsx +13 -15
- package/apps/studio/client/v2/ds/off-system-host.jsx +18 -19
- package/apps/studio/client/v2/ds/review-host.jsx +7 -1
- package/apps/studio/client/v2/ds/truth-host.jsx +15 -17
- package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
- package/apps/studio/client/v2/history/branch-actions.js +13 -9
- package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
- package/apps/studio/client/v2/history/git-model.js +3 -1
- package/apps/studio/client/v2/history/git-parts.jsx +16 -1
- package/apps/studio/client/v2/layers/artboard-layers.jsx +24 -5
- package/apps/studio/client/v2/layers/layers-request.js +49 -0
- package/apps/studio/client/v2/left-panel/canvases-pinned.jsx +93 -3
- package/apps/studio/client/v2/left-panel/ds-boards.js +39 -0
- package/apps/studio/client/v2/left-panel/left-panel-model.js +13 -0
- package/apps/studio/client/v2/left-panel/left-panel.css +24 -0
- package/apps/studio/client/v2/presence/faces.jsx +42 -14
- package/apps/studio/client/v2/shell/account-card.jsx +10 -4
- package/apps/studio/client/v2/shell/canvas-crash-guard.js +172 -0
- package/apps/studio/client/v2/shell/canvas-mode.js +17 -1
- package/apps/studio/client/v2/shell/floating-panels.css +37 -1
- package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
- package/apps/studio/client/v2/shell/menu-runner.js +11 -0
- package/apps/studio/client/v2/shell/mode-switch.jsx +14 -3
- package/apps/studio/client/v2/shell/opening-skeleton.js +118 -0
- package/apps/studio/client/v2/shell/opening-skeleton.jsx +103 -0
- package/apps/studio/client/v2/shell/pages-pick.js +49 -0
- package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
- package/apps/studio/client/v2/shell/project-account-model.js +182 -0
- package/apps/studio/client/v2/shell/project-menu-model.js +3 -0
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +140 -11
- package/apps/studio/client/v2/shell/share-cluster.css +58 -0
- package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
- package/apps/studio/client/v2/shell/shell-parity.json +8 -0
- package/apps/studio/client/v2/shell/team-switch.js +94 -0
- package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
- package/apps/studio/client/v2/shell/use-account.js +8 -1
- package/apps/studio/client/v2/shell/use-canvas-mode-lane.js +30 -0
- package/apps/studio/collab/persistence.ts +9 -1
- package/apps/studio/collab/registry.ts +32 -0
- package/apps/studio/collab/room.ts +8 -0
- package/apps/studio/comments-overlay.tsx +12 -11
- package/apps/studio/config-reload-wire.ts +56 -0
- package/apps/studio/config.schema.json +6 -0
- package/apps/studio/context.ts +37 -1
- package/apps/studio/dist/client.bundle.js +1198 -1198
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/ds/board/board.css +6 -0
- package/apps/studio/ds/board/ds-bar.tsx +21 -3
- package/apps/studio/ds/board/specimen.tsx +16 -2
- package/apps/studio/ds/board/template.ts +39 -19
- package/apps/studio/ds/canvas-cli.ts +58 -2
- package/apps/studio/ds/check.ts +26 -1
- package/apps/studio/ds/cli.ts +14 -4
- package/apps/studio/ds/component-list.ts +2 -1
- package/apps/studio/ds/convert.ts +34 -6
- package/apps/studio/ds/default.ts +6 -1
- package/apps/studio/ds/ds-resolver.ts +58 -8
- package/apps/studio/ds/ds-verb.ts +13 -0
- package/apps/studio/ds/engine.ts +3 -1
- package/apps/studio/ds/folder-systems.ts +199 -0
- package/apps/studio/ds/pairing-css.ts +2 -1
- package/apps/studio/ds/post-build.ts +38 -0
- package/apps/studio/ds/rename.ts +10 -3
- package/apps/studio/ds/shell-fallbacks.ts +2 -1
- package/apps/studio/ds/upgrade-apply.ts +27 -5
- package/apps/studio/ds/upgrade-cli.ts +22 -2
- package/apps/studio/ds/upgrade-prove.ts +198 -15
- package/apps/studio/ds/upgrade-stage.ts +10 -3
- package/apps/studio/editing/ai-point-ring.tsx +4 -4
- package/apps/studio/editing/ai-scope-outline.tsx +4 -4
- package/apps/studio/editing/align-bar.tsx +4 -4
- package/apps/studio/editing/anchor-report.ts +3 -2
- package/apps/studio/editing/artboard-handles.tsx +4 -4
- package/apps/studio/editing/corner-dots.tsx +4 -4
- package/apps/studio/editing/crop-mode.tsx +4 -4
- package/apps/studio/editing/drop-chip.tsx +4 -4
- package/apps/studio/editing/empty-report.ts +3 -2
- package/apps/studio/editing/focus-model.tsx +4 -4
- package/apps/studio/editing/gap-bands.tsx +3 -3
- package/apps/studio/editing/hold-rings.tsx +4 -4
- package/apps/studio/editing/lock-badge.tsx +3 -3
- package/apps/studio/editing/long-page.ts +23 -1
- package/apps/studio/editing/nudge.tsx +2 -2
- package/apps/studio/editing/page-activity.ts +4 -3
- package/apps/studio/editing/paste-bar.tsx +4 -4
- package/apps/studio/editing/pen/overlay.tsx +4 -3
- package/apps/studio/editing/place-freely.tsx +3 -3
- package/apps/studio/editing/reorder-slot.tsx +3 -3
- package/apps/studio/editing/selection.tsx +4 -4
- package/apps/studio/editing/size-ghost.tsx +4 -4
- package/apps/studio/editing/tab-order.tsx +4 -4
- package/apps/studio/editing/text-in-place.tsx +4 -4
- package/apps/studio/editing/undo-preview.tsx +3 -3
- package/apps/studio/equal-spacing-handles.tsx +3 -3
- package/apps/studio/frame-clock.ts +89 -0
- package/apps/studio/history/trash.ts +6 -0
- package/apps/studio/home/accounts.ts +87 -0
- package/apps/studio/home/index-reader.ts +24 -2
- package/apps/studio/home/routes.ts +19 -0
- package/apps/studio/http.ts +80 -34
- package/apps/studio/index/ds-usage.ts +4 -1
- package/apps/studio/index-cache.ts +272 -0
- package/apps/studio/inspect-overlay.tsx +4 -3
- package/apps/studio/inspect.ts +7 -2
- package/apps/studio/link-chip-overlay.tsx +4 -3
- package/apps/studio/measure-overlay.tsx +4 -3
- package/apps/studio/present/pointer-dot.tsx +3 -2
- package/apps/studio/present/present-media.ts +6 -2
- package/apps/studio/present/present-stage.tsx +3 -2
- package/apps/studio/preview/preview-camera.tsx +3 -2
- package/apps/studio/routes/ds-convert.ts +18 -0
- package/apps/studio/routes/sync.ts +176 -0
- package/apps/studio/routes/trash.ts +16 -1
- package/apps/studio/safe-zones-overlay.tsx +3 -2
- package/apps/studio/server.ts +8 -10
- package/apps/studio/skip-dirs.ts +103 -47
- package/apps/studio/studio-page-host.ts +70 -0
- package/apps/studio/sync/accepted-cold-start.ts +28 -13
- package/apps/studio/sync/asset-push.ts +146 -23
- package/apps/studio/sync/asset-state.ts +3 -2
- package/apps/studio/sync/code-module-consent.ts +86 -0
- package/apps/studio/sync/file-ledger.ts +24 -0
- package/apps/studio/sync/file-membership.ts +28 -3
- package/apps/studio/sync/file-plane.ts +497 -61
- package/apps/studio/sync/file-pull.ts +304 -33
- package/apps/studio/sync/held-deletes.ts +230 -0
- package/apps/studio/sync/hub-link.ts +1 -2
- package/apps/studio/sync/hubs-config.ts +59 -2
- package/apps/studio/sync/index.ts +405 -163
- package/apps/studio/sync/journal-client.ts +94 -5
- package/apps/studio/sync/pending-deletes.ts +100 -0
- package/apps/studio/sync/projection.ts +77 -12
- package/apps/studio/sync/seed-progress.ts +104 -3
- package/apps/studio/sync/settings.ts +36 -1
- package/apps/studio/sync/status.ts +17 -1
- package/apps/studio/sync/writer-registry.ts +5 -0
- package/apps/studio/text-caret.ts +5 -3
- package/apps/studio/thumbs/service.ts +12 -2
- package/apps/studio/thumbs/validate.ts +7 -0
- package/apps/studio/toolbars/toolbar-rect.ts +3 -2
- package/apps/studio/ui-prefs-migrate.ts +4 -0
- package/apps/studio/use-annotation-resize.tsx +4 -3
- package/apps/studio/use-artboard-drag.tsx +3 -2
- package/apps/studio/use-element-resize.tsx +7 -6
- package/apps/studio/use-grid-track-handles.tsx +5 -4
- package/apps/studio/use-selection-set.tsx +64 -4
- package/apps/studio/use-spacing-handles.tsx +7 -6
- package/apps/studio/video-comp.tsx +75 -39
- package/apps/studio/video-play-overlay.tsx +4 -3
- package/apps/studio/whats-new.json +99 -0
- package/cli/commands/design.mjs +5 -2
- package/cli/commands/hub.mjs +10 -1
- package/cli/lib/bash-guard.mjs +27 -1
- package/cli/lib/design-help.gen.mjs +1 -1
- package/cli/lib/design-hook.mjs +20 -0
- package/cli/lib/design-link.mjs +42 -17
- package/cli/lib/hub-purge.mjs +183 -0
- package/cli/lib/studio-locate.mjs +35 -10
- package/package.json +8 -8
- package/plugins/design/templates/_shell.html +164 -1
|
@@ -65,13 +65,16 @@ import { open as openAsync } from 'node:fs/promises';
|
|
|
65
65
|
import path from 'node:path';
|
|
66
66
|
|
|
67
67
|
import { conflictCopyName, decideFile, type FileState } from './decide-file.ts';
|
|
68
|
-
import type { DeliveryState, FileLedger } from './file-ledger.ts';
|
|
68
|
+
import type { DeliveryState, FileLedger, LedgerRow } from './file-ledger.ts';
|
|
69
69
|
import {
|
|
70
70
|
type CanvasGroupLike,
|
|
71
71
|
classifyProjectFile,
|
|
72
72
|
type FileClass,
|
|
73
73
|
isFilePlaneClass,
|
|
74
|
+
MAX_SEGMENTS,
|
|
75
|
+
OLDER_HUB_DEPTH_REASON,
|
|
74
76
|
olderDoorRefuses,
|
|
77
|
+
olderDoorRefusesDepth,
|
|
75
78
|
} from './file-membership.ts';
|
|
76
79
|
import {
|
|
77
80
|
fetchJournal,
|
|
@@ -84,6 +87,7 @@ import { createPullBudget } from './pull-budget.ts';
|
|
|
84
87
|
import { createPullPacer, type PullPacer } from './pull-pacer.ts';
|
|
85
88
|
import { activeCanvasWants } from './pull-priority.ts';
|
|
86
89
|
import { failureReason, isBackpressure, refusalWords, retryAfterMs } from './retry-after.ts';
|
|
90
|
+
import { DELETED_HERE_HELD_REASON } from './seed-progress.ts';
|
|
87
91
|
import { classifyTransportError } from './transport-error.ts';
|
|
88
92
|
|
|
89
93
|
/** How long to wait for one file's bytes. Generous — these run to videos. */
|
|
@@ -108,6 +112,9 @@ export const MAX_FILE_BYTES = (() => {
|
|
|
108
112
|
* happens, so it is kept at a size where twice the file does not matter. */
|
|
109
113
|
export const STREAM_DOWNLOAD_ABOVE_BYTES = 1024 * 1024;
|
|
110
114
|
|
|
115
|
+
/** Issue #207 — above this an upload body streams from disk instead of being read into memory. */
|
|
116
|
+
export const STREAM_UPLOAD_ABOVE_BYTES = 1024 * 1024;
|
|
117
|
+
|
|
111
118
|
/** sha256 of a file, read in 1 MiB chunks (T18 — a video is never held whole). */
|
|
112
119
|
export function sha256File(abs: string): string {
|
|
113
120
|
const hash = createHash('sha256');
|
|
@@ -363,6 +370,7 @@ function deliveryRank(state: DeliveryState): number {
|
|
|
363
370
|
case 'refused':
|
|
364
371
|
return 1;
|
|
365
372
|
case 'stuck':
|
|
373
|
+
case 'delete-held':
|
|
366
374
|
return 2;
|
|
367
375
|
case 'referenced-but-unoffered':
|
|
368
376
|
return 3;
|
|
@@ -375,8 +383,8 @@ function deliveryRank(state: DeliveryState): number {
|
|
|
375
383
|
}
|
|
376
384
|
}
|
|
377
385
|
|
|
378
|
-
/** Walk depth ceiling —
|
|
379
|
-
const MAX_WALK_DEPTH =
|
|
386
|
+
/** Walk depth ceiling — the classifier's own shape cap (32 since fix/205). */
|
|
387
|
+
const MAX_WALK_DEPTH = MAX_SEGMENTS;
|
|
380
388
|
|
|
381
389
|
/** Directories no plane path can live under. */
|
|
382
390
|
const SKIPPED_DIRS = new Set(['_trash', '_history', '_untrusted', '_smoke', 'node_modules']);
|
|
@@ -423,6 +431,12 @@ export interface FilePlaneResult {
|
|
|
423
431
|
requestsExhausted?: true;
|
|
424
432
|
/** The pass stopped because it had moved `MAX_FILES_PER_PASS` files (issue #204). */
|
|
425
433
|
filesCapped?: true;
|
|
434
|
+
/** Issue #207 — uploads cancelled because the file left this Mac after the scan (not failures). */
|
|
435
|
+
gone?: number;
|
|
436
|
+
/** Issue #207 — files on this disk inside a folder the project does not sync (`linkedHub.ignoreFolders`). */
|
|
437
|
+
ignored?: number;
|
|
438
|
+
/** Issue #207 — folders with a long run of pictures still going up (see `largeSequences`). */
|
|
439
|
+
largeSequences?: LargeSequence[];
|
|
426
440
|
/**
|
|
427
441
|
* Issue #204 — files whose bytes the hub is still FETCHING FROM ITS BUCKET (a cold cell's
|
|
428
442
|
* `503 fetching from storage`). Not delivered, not failed, not stuck: each is backed off for the
|
|
@@ -452,8 +466,16 @@ export interface FilePlaneResult {
|
|
|
452
466
|
backedOff?: number;
|
|
453
467
|
/** Files removed this pass — `parked` names the `_trash/` copy when there is one. */
|
|
454
468
|
deleted: { rel: string; parked: string | null }[];
|
|
455
|
-
/**
|
|
456
|
-
|
|
469
|
+
/**
|
|
470
|
+
* A delete burst tripped a breaker; nothing was removed. Outbound, it is every row still waiting
|
|
471
|
+
* for the person's answer (`delete-held`), with the folders they sit in (issue #207, 7b).
|
|
472
|
+
*/
|
|
473
|
+
deleteHeld?: {
|
|
474
|
+
direction: 'out' | 'in';
|
|
475
|
+
count: number;
|
|
476
|
+
paths: string[];
|
|
477
|
+
folders?: HeldDeleteFolder[];
|
|
478
|
+
};
|
|
457
479
|
/** Consecutive `reanchor` answers tripped the storm limit; the pass held. */
|
|
458
480
|
reanchorHeld?: true;
|
|
459
481
|
/**
|
|
@@ -498,8 +520,12 @@ export interface FilePlaneOptions {
|
|
|
498
520
|
* LOCAL state (hubs.json role / loopback pairing) — never from anything the
|
|
499
521
|
* hub said. The hub gates the write side too now, but a gate on one side is
|
|
500
522
|
* half a gate, so both ask.
|
|
523
|
+
*
|
|
524
|
+
* fix/207 — may be a function, read at every gate: the person can say yes (or no) in the app
|
|
525
|
+
* while sync runs (`POST /_api/sync/code-consent/set`), and the very next pass must admit the
|
|
526
|
+
* rows it held — no restart. A boolean keeps the old fixed reading.
|
|
501
527
|
*/
|
|
502
|
-
allowCodeModules: boolean;
|
|
528
|
+
allowCodeModules: boolean | (() => boolean);
|
|
503
529
|
/**
|
|
504
530
|
* Whether this peer may SEND a `code-module` the hub does not hold yet. The
|
|
505
531
|
* hub's file door takes one only from an owner-role token (403 otherwise);
|
|
@@ -511,8 +537,19 @@ export interface FilePlaneOptions {
|
|
|
511
537
|
canUploadCodeModules?: boolean;
|
|
512
538
|
/** Names conflict copies. Same exposure class as `syncMeta.by` (hostname). */
|
|
513
539
|
label: string;
|
|
514
|
-
/**
|
|
515
|
-
|
|
540
|
+
/**
|
|
541
|
+
* Increment 6. Off means a local absence is HELD, never propagated. A getter is read at the
|
|
542
|
+
* start of every pass (issue #207), so turning it off or on in the project config applies at the
|
|
543
|
+
* next pass — Resync — instead of at the next restart.
|
|
544
|
+
*/
|
|
545
|
+
propagateDeletes?: boolean | (() => boolean);
|
|
546
|
+
/**
|
|
547
|
+
* Issue #207 — design-root-relative folders this project does not sync
|
|
548
|
+
* (`linkedHub.ignoreFolders` in the project config). Nothing under them moves either way.
|
|
549
|
+
* A getter is read at the start of every pass, so a folder left out mid-upload stops at the
|
|
550
|
+
* next pass instead of at the next restart.
|
|
551
|
+
*/
|
|
552
|
+
ignoreFolders?: readonly string[] | (() => readonly string[]);
|
|
516
553
|
/**
|
|
517
554
|
* The outbound delete breaker is OFF: a deliberate bulk delete on this
|
|
518
555
|
* machine propagates in one pass. Computed by the caller from LOCAL consent
|
|
@@ -581,6 +618,12 @@ export interface FilePlaneOptions {
|
|
|
581
618
|
* true (every caller before this option, and every test hub, takes them).
|
|
582
619
|
*/
|
|
583
620
|
hubTakesV2Files?: boolean;
|
|
621
|
+
/**
|
|
622
|
+
* fix/205 — the hub advertises `file-depth-v2` (`hasFileDepthV2`). False ⇒ a path deeper than
|
|
623
|
+
* 8 segments (`olderDoorRefusesDepth`) is held here with a reason and never offered. Absent ⇒
|
|
624
|
+
* true, like `hubTakesV2Files`.
|
|
625
|
+
*/
|
|
626
|
+
hubTakesDeepPaths?: boolean;
|
|
584
627
|
/**
|
|
585
628
|
* Issue #204 — how fast this plane talks to the hub (concurrency + requests per minute). One per
|
|
586
629
|
* plane so the adaptive width survives from pass to pass. Default: `createPullPacer()`.
|
|
@@ -625,18 +668,238 @@ type LocalFile = SyncableLocalFile | OversizedLocalFile;
|
|
|
625
668
|
const sha256 = (bytes: Uint8Array | string): string =>
|
|
626
669
|
createHash('sha256').update(bytes).digest('hex');
|
|
627
670
|
|
|
671
|
+
interface WalkedFile {
|
|
672
|
+
rel: string;
|
|
673
|
+
abs: string;
|
|
674
|
+
size: number;
|
|
675
|
+
mtimeMs: number;
|
|
676
|
+
}
|
|
677
|
+
|
|
628
678
|
/**
|
|
629
|
-
* Walk the design root and hash what the classifier admits.
|
|
679
|
+
* Walk the design root and hash what the classifier admits — synchronously.
|
|
630
680
|
*
|
|
631
681
|
* The stat cache is what makes this cheap: a converged project re-reads
|
|
632
682
|
* nothing, because every file's `(size, mtimeMs)` still matches the ledger.
|
|
683
|
+
* The plane itself scans with `scanLocalFilesAsync` (issue #207); this stays
|
|
684
|
+
* for callers with no event loop to protect.
|
|
633
685
|
*/
|
|
634
686
|
export function scanLocalFiles(
|
|
635
687
|
designRoot: string,
|
|
636
688
|
ledger: FileLedger,
|
|
637
689
|
canvasGroups?: readonly CanvasGroupLike[]
|
|
638
690
|
): Map<string, LocalFile> {
|
|
639
|
-
const
|
|
691
|
+
const out = new Map<string, LocalFile>();
|
|
692
|
+
for (const { f, cls } of walkAndClassify(designRoot, canvasGroups)) {
|
|
693
|
+
if (f.size > MAX_FILE_BYTES) {
|
|
694
|
+
out.set(f.rel, { ...f, cls, hash: null, oversized: true });
|
|
695
|
+
continue;
|
|
696
|
+
}
|
|
697
|
+
let hash = ledger.cachedHash(f.rel, f.size, f.mtimeMs);
|
|
698
|
+
if (hash === null) {
|
|
699
|
+
try {
|
|
700
|
+
hash = sha256File(f.abs);
|
|
701
|
+
} catch {
|
|
702
|
+
continue;
|
|
703
|
+
}
|
|
704
|
+
ledger.noteLocal(f.rel, hash, f.size, f.mtimeMs);
|
|
705
|
+
}
|
|
706
|
+
out.set(f.rel, { rel: f.rel, abs: f.abs, hash, size: f.size, mtimeMs: f.mtimeMs, cls });
|
|
707
|
+
}
|
|
708
|
+
return out;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* The longest stretch of scan work before it yields to the event loop.
|
|
713
|
+
* Issue #207: the scan hashed every uncached file in ONE synchronous run
|
|
714
|
+
* (2 000 new 0.5–3 MB renders held the loop for 7.7 s) and the studio's
|
|
715
|
+
* `/_health` waited for all of it. Hashing now reads through a stream and
|
|
716
|
+
* yields every slice — inside a file as well as between files, because a
|
|
717
|
+
* stream whose chunks are already read ahead resolves on MICROTASKS, which
|
|
718
|
+
* never let a request in — so a request waits one slice at most.
|
|
719
|
+
*/
|
|
720
|
+
export const SCAN_SLICE_MS = 8;
|
|
721
|
+
|
|
722
|
+
/** What the panel says about a file in a folder the project does not sync. */
|
|
723
|
+
export const IGNORED_REASON = 'In a folder this project does not sync';
|
|
724
|
+
|
|
725
|
+
/** Issue #207 (7b) — the ledger reason for a `delete-held` row. */
|
|
726
|
+
export const DELETE_HELD_REASON =
|
|
727
|
+
'deleted on this Mac, as part of a batch too large to delete on the hub without asking';
|
|
728
|
+
/** Issue #207 (7b) — the ledger reason for a `hub-only` row. */
|
|
729
|
+
export const HUB_ONLY_REASON =
|
|
730
|
+
'deleted on this Mac and kept on the hub — it is not downloaded again';
|
|
731
|
+
|
|
732
|
+
/** One folder of held deletes, for the Sync details row. */
|
|
733
|
+
export interface HeldDeleteFolder {
|
|
734
|
+
/** Design-root-relative folder (`''` = the design root itself). */
|
|
735
|
+
folder: string;
|
|
736
|
+
count: number;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/** The folder a held row sits in. */
|
|
740
|
+
export function heldDeleteFolderOf(rel: string): string {
|
|
741
|
+
const i = rel.lastIndexOf('/');
|
|
742
|
+
return i < 0 ? '' : rel.slice(0, i);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
/** Every `delete-held` row, grouped by folder (largest first) — pure over the ledger's rows. */
|
|
746
|
+
export function summarizeHeldDeletes(rows: Readonly<Record<string, LedgerRow>>): {
|
|
747
|
+
count: number;
|
|
748
|
+
paths: string[];
|
|
749
|
+
folders: HeldDeleteFolder[];
|
|
750
|
+
} {
|
|
751
|
+
const paths: string[] = [];
|
|
752
|
+
const byFolder = new Map<string, number>();
|
|
753
|
+
for (const [rel, row] of Object.entries(rows)) {
|
|
754
|
+
if (row.state !== 'delete-held') continue;
|
|
755
|
+
paths.push(rel);
|
|
756
|
+
const f = heldDeleteFolderOf(rel);
|
|
757
|
+
byFolder.set(f, (byFolder.get(f) ?? 0) + 1);
|
|
758
|
+
}
|
|
759
|
+
paths.sort();
|
|
760
|
+
const folders = [...byFolder.entries()]
|
|
761
|
+
.map(([folder, count]) => ({ folder, count }))
|
|
762
|
+
.sort((a, b) => b.count - a.count || (a.folder < b.folder ? -1 : 1));
|
|
763
|
+
return { count: paths.length, paths, folders };
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/** Does `rel` sit in `folder` (or below it)? `null` folder = every held row. */
|
|
767
|
+
export function inHeldFolder(rel: string, folder: string | null): boolean {
|
|
768
|
+
if (folder === null) return true;
|
|
769
|
+
if (folder === '') return !rel.includes('/');
|
|
770
|
+
return rel.startsWith(`${folder}/`);
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* The folders a project does not sync, cleaned: design-root-relative, no
|
|
775
|
+
* leading/trailing slash, contained (a `..` or absolute entry is dropped — the
|
|
776
|
+
* list comes from a committed file a teammate may have written), and never a
|
|
777
|
+
* runtime-state (`_`) top folder, which the plane never walks anyway.
|
|
778
|
+
*/
|
|
779
|
+
export function normalizeIgnoreFolders(raw: unknown): string[] {
|
|
780
|
+
if (!Array.isArray(raw)) return [];
|
|
781
|
+
const out = new Set<string>();
|
|
782
|
+
for (const v of raw) {
|
|
783
|
+
if (typeof v !== 'string') continue;
|
|
784
|
+
const p = path.posix.normalize(v.replace(/\\/g, '/').trim()).replace(/^\/+|\/+$/g, '');
|
|
785
|
+
if (!p || p === '.' || p === '..' || p.startsWith('../') || /^[A-Za-z]:/.test(v)) continue;
|
|
786
|
+
if (v.trim().startsWith('/')) continue;
|
|
787
|
+
out.add(p);
|
|
788
|
+
}
|
|
789
|
+
return [...out];
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/** True when `rel` is one of the folders, or inside one. */
|
|
793
|
+
export function isIgnoredRel(rel: string, folders: readonly string[]): boolean {
|
|
794
|
+
for (const f of folders) if (rel === f || rel.startsWith(`${f}/`)) return true;
|
|
795
|
+
return false;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/** Issue #207 — a folder whose pictures still going up pass either of these is named in the panel. */
|
|
799
|
+
export const LARGE_SEQUENCE_FILES = 200;
|
|
800
|
+
export const LARGE_SEQUENCE_BYTES = 200 * 1024 * 1024;
|
|
801
|
+
const PICTURE_EXT_RE = /\.(png|jpe?g|webp|avif|gif|tiff?|exr|bmp|heic|tga|dpx|psd)$/i;
|
|
802
|
+
|
|
803
|
+
export interface LargeSequence {
|
|
804
|
+
/** Design-root-relative folder. */
|
|
805
|
+
folder: string;
|
|
806
|
+
files: number;
|
|
807
|
+
bytes: number;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Folders holding a long run of pictures that this pass still has to send up —
|
|
812
|
+
* a render sequence, a frame dump. Only uploads count (what is already on the
|
|
813
|
+
* workspace is not news); at most five folders, largest first.
|
|
814
|
+
*/
|
|
815
|
+
export function largeSequences(
|
|
816
|
+
work: readonly { rel: string; decision: { action: string }; local?: { size: number } }[]
|
|
817
|
+
): LargeSequence[] {
|
|
818
|
+
const byFolder = new Map<string, { files: number; bytes: number }>();
|
|
819
|
+
for (const w of work) {
|
|
820
|
+
if (w.decision.action !== 'push' && w.decision.action !== 'revive') continue;
|
|
821
|
+
if (!PICTURE_EXT_RE.test(w.rel)) continue;
|
|
822
|
+
const folder = path.posix.dirname(w.rel);
|
|
823
|
+
if (folder === '.') continue;
|
|
824
|
+
const s = byFolder.get(folder) ?? { files: 0, bytes: 0 };
|
|
825
|
+
s.files += 1;
|
|
826
|
+
s.bytes += w.local?.size ?? 0;
|
|
827
|
+
byFolder.set(folder, s);
|
|
828
|
+
}
|
|
829
|
+
return [...byFolder]
|
|
830
|
+
.filter(([, s]) => s.files > LARGE_SEQUENCE_FILES || s.bytes > LARGE_SEQUENCE_BYTES)
|
|
831
|
+
.map(([folder, s]) => ({ folder, ...s }))
|
|
832
|
+
.sort((a, b) => b.bytes - a.bytes)
|
|
833
|
+
.slice(0, 5);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
/** Hand the event loop a turn (a macrotask: pending I/O and timers run first). */
|
|
837
|
+
export const yieldToLoop = (): Promise<void> => new Promise((r) => setImmediate(r));
|
|
838
|
+
|
|
839
|
+
/** A time-sliced yield: `await slice()` yields once `ms` of work has run since the last turn. */
|
|
840
|
+
export function createSlicer(ms = SCAN_SLICE_MS): () => Promise<void> {
|
|
841
|
+
let start = performance.now();
|
|
842
|
+
return async () => {
|
|
843
|
+
if (performance.now() - start < ms) return;
|
|
844
|
+
await yieldToLoop();
|
|
845
|
+
start = performance.now();
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* sha256 of a file through `Bun.file().stream()` — issue #207. Memory is the
|
|
851
|
+
* stream's read-ahead (~30 MB measured on a 256 MB file, never the file), and
|
|
852
|
+
* it yields to the event loop every slice, so a large file never blocks it.
|
|
853
|
+
*/
|
|
854
|
+
export async function hashFileStreamed(
|
|
855
|
+
abs: string,
|
|
856
|
+
slice: () => Promise<void> = createSlicer()
|
|
857
|
+
): Promise<string> {
|
|
858
|
+
const hasher = new Bun.CryptoHasher('sha256');
|
|
859
|
+
for await (const chunk of Bun.file(abs).stream()) {
|
|
860
|
+
hasher.update(chunk);
|
|
861
|
+
await slice();
|
|
862
|
+
}
|
|
863
|
+
return hasher.digest('hex');
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* The plane's scan: the same answer as `scanLocalFiles`, but hashed through a
|
|
868
|
+
* stream and yielding to the event loop every `SCAN_SLICE_MS` (issue #207).
|
|
869
|
+
*/
|
|
870
|
+
export async function scanLocalFilesAsync(
|
|
871
|
+
designRoot: string,
|
|
872
|
+
ledger: FileLedger,
|
|
873
|
+
canvasGroups?: readonly CanvasGroupLike[]
|
|
874
|
+
): Promise<Map<string, LocalFile>> {
|
|
875
|
+
const slice = createSlicer();
|
|
876
|
+
const out = new Map<string, LocalFile>();
|
|
877
|
+
for (const { f, cls } of walkAndClassify(designRoot, canvasGroups)) {
|
|
878
|
+
await slice();
|
|
879
|
+
if (f.size > MAX_FILE_BYTES) {
|
|
880
|
+
out.set(f.rel, { ...f, cls, hash: null, oversized: true });
|
|
881
|
+
continue;
|
|
882
|
+
}
|
|
883
|
+
let hash = ledger.cachedHash(f.rel, f.size, f.mtimeMs);
|
|
884
|
+
if (hash === null) {
|
|
885
|
+
try {
|
|
886
|
+
hash = await hashFileStreamed(f.abs, slice);
|
|
887
|
+
} catch {
|
|
888
|
+
continue;
|
|
889
|
+
}
|
|
890
|
+
ledger.noteLocal(f.rel, hash, f.size, f.mtimeMs);
|
|
891
|
+
}
|
|
892
|
+
out.set(f.rel, { rel: f.rel, abs: f.abs, hash, size: f.size, mtimeMs: f.mtimeMs, cls });
|
|
893
|
+
}
|
|
894
|
+
return out;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/** Walk the design root (stat only, no reads) and keep what the classifier admits. */
|
|
898
|
+
function walkAndClassify(
|
|
899
|
+
designRoot: string,
|
|
900
|
+
canvasGroups?: readonly CanvasGroupLike[]
|
|
901
|
+
): { f: WalkedFile; cls: FileClass }[] {
|
|
902
|
+
const found: WalkedFile[] = [];
|
|
640
903
|
|
|
641
904
|
const walk = (dir: string, rel: string, depth: number): void => {
|
|
642
905
|
if (depth > MAX_WALK_DEPTH) return;
|
|
@@ -674,24 +937,10 @@ export function scanLocalFiles(
|
|
|
674
937
|
const names = new Set(found.map((f) => f.rel));
|
|
675
938
|
const opts = { canvasGroups, hasFile: (r: string) => names.has(r) };
|
|
676
939
|
|
|
677
|
-
const out
|
|
940
|
+
const out: { f: WalkedFile; cls: FileClass }[] = [];
|
|
678
941
|
for (const f of found) {
|
|
679
942
|
const cls = classifyProjectFile(f.rel, opts);
|
|
680
|
-
if (
|
|
681
|
-
if (f.size > MAX_FILE_BYTES) {
|
|
682
|
-
out.set(f.rel, { ...f, cls, hash: null, oversized: true });
|
|
683
|
-
continue;
|
|
684
|
-
}
|
|
685
|
-
let hash = ledger.cachedHash(f.rel, f.size, f.mtimeMs);
|
|
686
|
-
if (hash === null) {
|
|
687
|
-
try {
|
|
688
|
-
hash = sha256File(f.abs);
|
|
689
|
-
} catch {
|
|
690
|
-
continue;
|
|
691
|
-
}
|
|
692
|
-
ledger.noteLocal(f.rel, hash, f.size, f.mtimeMs);
|
|
693
|
-
}
|
|
694
|
-
out.set(f.rel, { rel: f.rel, abs: f.abs, hash, size: f.size, mtimeMs: f.mtimeMs, cls });
|
|
943
|
+
if (isFilePlaneClass(cls)) out.push({ f, cls });
|
|
695
944
|
}
|
|
696
945
|
return out;
|
|
697
946
|
}
|
|
@@ -726,14 +975,43 @@ export interface FilePlane {
|
|
|
726
975
|
unmeasured: number;
|
|
727
976
|
byClass: Record<string, { files: number; bytes: number }>;
|
|
728
977
|
} | null;
|
|
978
|
+
/** Issue #207 (7b) — the held local deletes, as Sync details shows them. */
|
|
979
|
+
heldDeletes(): ReturnType<typeof summarizeHeldDeletes>;
|
|
980
|
+
/**
|
|
981
|
+
* Issue #207 (7b) — the person's answer to held deletes (`folder` null = all of them). `send`: the
|
|
982
|
+
* next passes delete them through the hub's door, past this Mac's breaker. `purging`: a confirmed
|
|
983
|
+
* owner purge is deleting them on the hub — the plane leaves them alone until `endPurge`. `keep`:
|
|
984
|
+
* kept on the hub, never proposed or downloaded again. Returns the paths the answer covered.
|
|
985
|
+
*/
|
|
986
|
+
answerHeldDeletes(how: 'send' | 'purging' | 'keep', folder: string | null): string[];
|
|
987
|
+
/** The purge for these paths ended (done or not): held again unless the hub deleted them. */
|
|
988
|
+
endPurge(rels: readonly string[]): void;
|
|
729
989
|
}
|
|
730
990
|
|
|
731
991
|
export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
992
|
+
// fix/207 — the receive consent, read live (see `FilePlaneOptions.allowCodeModules`).
|
|
993
|
+
const mayReceiveCode = (): boolean =>
|
|
994
|
+
typeof opts.allowCodeModules === 'function'
|
|
995
|
+
? opts.allowCodeModules() === true
|
|
996
|
+
: opts.allowCodeModules === true;
|
|
997
|
+
const mayUploadCode = (): boolean => opts.canUploadCodeModules ?? mayReceiveCode();
|
|
732
998
|
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
733
999
|
const log = opts.log ?? console;
|
|
734
1000
|
const now = opts.now ?? Date.now;
|
|
735
1001
|
const base = opts.hubUrl.replace(/\/+$/, '');
|
|
736
1002
|
const { ledger, designRoot } = opts;
|
|
1003
|
+
/** Issue #207 (7b) — held deletes the person said to send through the door (in memory). */
|
|
1004
|
+
const confirmedDeletes = new Set<string>();
|
|
1005
|
+
/** Issue #207 (7b) — held deletes an owner purge is deleting on the hub right now. */
|
|
1006
|
+
const purgingDeletes = new Set<string>();
|
|
1007
|
+
const readPropagateDeletes = (): boolean =>
|
|
1008
|
+
(typeof opts.propagateDeletes === 'function'
|
|
1009
|
+
? opts.propagateDeletes()
|
|
1010
|
+
: opts.propagateDeletes) === true;
|
|
1011
|
+
const readIgnoreFolders = (): string[] =>
|
|
1012
|
+
normalizeIgnoreFolders(
|
|
1013
|
+
typeof opts.ignoreFolders === 'function' ? opts.ignoreFolders() : opts.ignoreFolders
|
|
1014
|
+
);
|
|
737
1015
|
/**
|
|
738
1016
|
* The design root with its own symlinks resolved. Containment is judged
|
|
739
1017
|
* against THIS, not the configured string — otherwise a project reached
|
|
@@ -1509,8 +1787,12 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
1509
1787
|
quotaExhausted?: true;
|
|
1510
1788
|
quotaResetsAt?: number;
|
|
1511
1789
|
permanent?: true;
|
|
1790
|
+
/** Issue #207 — the file is no longer on this Mac: cancelled, not failed. */
|
|
1791
|
+
gone?: true;
|
|
1512
1792
|
}
|
|
1513
1793
|
> {
|
|
1794
|
+
// A FILE THAT LEFT THIS MAC is not uploaded, and not retried (issue #207).
|
|
1795
|
+
if (!existsSync(local.abs)) return { ok: false, gone: true, reason: 'no longer on this Mac' };
|
|
1514
1796
|
// PRE-FLIGHT AGAINST THE DOOR'S OWN CEILING, before a byte is read.
|
|
1515
1797
|
//
|
|
1516
1798
|
// `tooLarge` is TERMINAL: the returned reason is stored and the caller
|
|
@@ -1544,10 +1826,28 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
1544
1826
|
}
|
|
1545
1827
|
// T18 — past one request: a resumable session, in verified parts.
|
|
1546
1828
|
if (local.size > singlePutCeiling()) return pushSession(local, expect);
|
|
1547
|
-
|
|
1829
|
+
// ISSUE #207 — A LARGE BODY STREAMS FROM DISK. Handing fetch the whole file
|
|
1830
|
+
// as one buffer cost TWICE the file in memory over TLS (measured: 532 MB of
|
|
1831
|
+
// RSS for a 256 MB body; a `Bun.file` body is no better there), copied on
|
|
1832
|
+
// the main thread — the memmove a desktop uploading thousands of renders
|
|
1833
|
+
// spent its time in. A stream costs its read-ahead. The hub hashes what
|
|
1834
|
+
// lands against `x-maude-content-sha256`, so a file that changes mid-flight
|
|
1835
|
+
// is refused there, never stored under the wrong hash.
|
|
1836
|
+
let bytes: Uint8Array | ReadableStream<Uint8Array>;
|
|
1548
1837
|
try {
|
|
1549
|
-
|
|
1838
|
+
if (local.size > STREAM_UPLOAD_ABOVE_BYTES) {
|
|
1839
|
+
const st = statSync(local.abs);
|
|
1840
|
+
if (st.size !== local.size || st.mtimeMs !== local.mtimeMs) {
|
|
1841
|
+
return { ok: false, reason: 'The file changed since it was read — it goes up next pass' };
|
|
1842
|
+
}
|
|
1843
|
+
bytes = Bun.file(local.abs).stream();
|
|
1844
|
+
} else {
|
|
1845
|
+
bytes = readFileSync(local.abs);
|
|
1846
|
+
}
|
|
1550
1847
|
} catch (err) {
|
|
1848
|
+
if ((err as NodeJS.ErrnoException)?.code === 'ENOENT') {
|
|
1849
|
+
return { ok: false, gone: true, reason: 'no longer on this Mac' };
|
|
1850
|
+
}
|
|
1551
1851
|
// A LOCAL DISK READ, not a transfer. Classifying it as a transport
|
|
1552
1852
|
// failure would tell a person the workspace is unreachable when the file
|
|
1553
1853
|
// is simply gone or unreadable — a wrong answer is worse than a vague one.
|
|
@@ -1571,6 +1871,9 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
1571
1871
|
'content-type': 'application/octet-stream',
|
|
1572
1872
|
'x-maude-content-sha256': local.hash,
|
|
1573
1873
|
'x-maude-expect-hash': expect ?? 'none',
|
|
1874
|
+
// A stream has no length of its own; the door and every proxy in
|
|
1875
|
+
// front of it see the same one a buffer would have carried.
|
|
1876
|
+
'content-length': String(local.size),
|
|
1574
1877
|
},
|
|
1575
1878
|
body: bytes as unknown as BodyInit,
|
|
1576
1879
|
signal: AbortSignal.timeout(PUT_TIMEOUT_MS),
|
|
@@ -1588,6 +1891,7 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
1588
1891
|
const body = (await res.json().catch(() => ({}))) as { seq?: unknown };
|
|
1589
1892
|
return { ok: true, seq: typeof body?.seq === 'number' ? body.seq : null };
|
|
1590
1893
|
} catch (err) {
|
|
1894
|
+
if (!existsSync(local.abs)) return { ok: false, gone: true, reason: 'no longer on this Mac' };
|
|
1591
1895
|
return { ok: false, reason: transportFailure(err, local.rel, log) };
|
|
1592
1896
|
} finally {
|
|
1593
1897
|
ledger.outboxDone(local.hash);
|
|
@@ -1791,7 +2095,7 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
1791
2095
|
* spent on them. A conflict, a refusal and an unoffered reference are not "on their way".
|
|
1792
2096
|
*/
|
|
1793
2097
|
function waitingHere(): number {
|
|
1794
|
-
const uploadsCode =
|
|
2098
|
+
const uploadsCode = mayUploadCode();
|
|
1795
2099
|
let n = 0;
|
|
1796
2100
|
for (const [rel, r] of Object.entries(ledger.rows())) {
|
|
1797
2101
|
if (r.state === 'stuck' || r.state === 'pushing') n += 1;
|
|
@@ -1819,9 +2123,9 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
1819
2123
|
* the hold can say how much waits. The scan only records observations (`noteLocal`) — no decision, no
|
|
1820
2124
|
* ancestor moves.
|
|
1821
2125
|
*/
|
|
1822
|
-
function holdAtCursor(out: FilePlaneResult): FilePlaneResult {
|
|
2126
|
+
async function holdAtCursor(out: FilePlaneResult): Promise<FilePlaneResult> {
|
|
1823
2127
|
if (hitRateLimit === null) return out;
|
|
1824
|
-
|
|
2128
|
+
await scanLocalFilesAsync(designRoot, ledger, opts.canvasGroups);
|
|
1825
2129
|
return holdIfRateLimited(out, waitingHere());
|
|
1826
2130
|
}
|
|
1827
2131
|
|
|
@@ -2068,7 +2372,9 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
2068
2372
|
if (fullRead && !page.truncated) ledger.pruneRemotes(new Set(delta.keys()));
|
|
2069
2373
|
|
|
2070
2374
|
// ── 2. Ours ──────────────────────────────────────────────────────────
|
|
2071
|
-
const
|
|
2375
|
+
const ignoreFolders = readIgnoreFolders();
|
|
2376
|
+
const propagateDeletes = readPropagateDeletes();
|
|
2377
|
+
const local = await scanLocalFilesAsync(designRoot, ledger, opts.canvasGroups);
|
|
2072
2378
|
|
|
2073
2379
|
// ── 3. Decide ────────────────────────────────────────────────────────
|
|
2074
2380
|
let work: {
|
|
@@ -2089,6 +2395,16 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
2089
2395
|
for (const rel of paths) {
|
|
2090
2396
|
const row = delta.get(rel);
|
|
2091
2397
|
const here = local.get(rel);
|
|
2398
|
+
// A FOLDER THE PERSON CHOSE NOT TO SYNC (issue #207, `linkedHub.ignoreFolders`). Nothing
|
|
2399
|
+
// moves in either direction — no upload, no download, no delete — and what the workspace
|
|
2400
|
+
// already holds stays there. Reported as `ignored`, never as waiting.
|
|
2401
|
+
if (ignoreFolders.length > 0 && isIgnoredRel(rel, ignoreFolders)) {
|
|
2402
|
+
if (here && ledger.row(rel)?.state !== 'ignored') {
|
|
2403
|
+
ledger.setState(rel, 'ignored', { reason: IGNORED_REASON });
|
|
2404
|
+
}
|
|
2405
|
+
if (here) out.ignored = (out.ignored ?? 0) + 1;
|
|
2406
|
+
continue;
|
|
2407
|
+
}
|
|
2092
2408
|
// HELD, NOT ABSENT. A file this peer cannot move is still a file: no
|
|
2093
2409
|
// decision may read it as deleted here or missing here.
|
|
2094
2410
|
if (here?.oversized) {
|
|
@@ -2154,7 +2470,7 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
2154
2470
|
// recorded (by push, or by agreement) was all `tombstone-agreed` needed
|
|
2155
2471
|
// to quarantine a code module on the word of a hub that may not move
|
|
2156
2472
|
// one. Refuse it here, reported, with the file and its row untouched.
|
|
2157
|
-
if (row?.deleted && here && !
|
|
2473
|
+
if (row?.deleted && here && !mayReceiveCode()) {
|
|
2158
2474
|
const cls = classifyProjectFile(rel, {
|
|
2159
2475
|
canvasGroups: opts.canvasGroups,
|
|
2160
2476
|
hasFile: (r) => local.has(r) || existsSync(path.join(designRoot, r)),
|
|
@@ -2191,7 +2507,7 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
2191
2507
|
drop(out, rel, `classifies '${cls}' here`, ledger);
|
|
2192
2508
|
continue;
|
|
2193
2509
|
}
|
|
2194
|
-
if (cls === 'code-module' && !
|
|
2510
|
+
if (cls === 'code-module' && !mayReceiveCode()) {
|
|
2195
2511
|
// AGREEMENT IS NOT A TRANSFER. The gate refuses to move a code
|
|
2196
2512
|
// module from an unvouched hub (DDR-054); identical bytes on both
|
|
2197
2513
|
// sides move nothing, and reporting them as refused left a
|
|
@@ -2215,10 +2531,7 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
2215
2531
|
// hub moved, or there is no agreed ancestor — still never lands here.
|
|
2216
2532
|
const ancestor = ledger.ancestorOf(rel);
|
|
2217
2533
|
const uploadOnly =
|
|
2218
|
-
here !== undefined &&
|
|
2219
|
-
ancestor !== null &&
|
|
2220
|
-
ancestor === remoteHash &&
|
|
2221
|
-
(opts.canUploadCodeModules ?? opts.allowCodeModules);
|
|
2534
|
+
here !== undefined && ancestor !== null && ancestor === remoteHash && mayUploadCode();
|
|
2222
2535
|
if (!uploadOnly) {
|
|
2223
2536
|
drop(
|
|
2224
2537
|
out,
|
|
@@ -2239,7 +2552,7 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
2239
2552
|
// it (2026-10-02, alligators: five `ui/club-web/_*.ts`, 264 refusals,
|
|
2240
2553
|
// passes stopped with 2 500+ paths still to do). Never ask: report it,
|
|
2241
2554
|
// keep the file, and let the rest of the pass run.
|
|
2242
|
-
if (remoteHash === null && here && !(
|
|
2555
|
+
if (remoteHash === null && here && !mayUploadCode()) {
|
|
2243
2556
|
const cls = classifyProjectFile(rel, {
|
|
2244
2557
|
canvasGroups: opts.canvasGroups,
|
|
2245
2558
|
hasFile: (r) => local.has(r) || existsSync(path.join(designRoot, r)),
|
|
@@ -2257,11 +2570,17 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
2257
2570
|
// answers `400 invalid path` to every 2.0-only file; asking costs a
|
|
2258
2571
|
// request and tells nobody anything. Held with a reason instead — and
|
|
2259
2572
|
// offered again the pass this hub advertises `file-classes-v2`.
|
|
2573
|
+
// fix/205 — the same for a path deeper than an older door takes (8 segments).
|
|
2574
|
+
const olderHubReason =
|
|
2575
|
+
here && remoteHash === null
|
|
2576
|
+
? opts.hubTakesV2Files === false && olderDoorRefuses(rel)
|
|
2577
|
+
? OLDER_HUB_REASON
|
|
2578
|
+
: opts.hubTakesDeepPaths === false && olderDoorRefusesDepth(rel)
|
|
2579
|
+
? OLDER_HUB_DEPTH_REASON
|
|
2580
|
+
: null
|
|
2581
|
+
: null;
|
|
2260
2582
|
if (
|
|
2261
|
-
|
|
2262
|
-
remoteHash === null &&
|
|
2263
|
-
opts.hubTakesV2Files === false &&
|
|
2264
|
-
olderDoorRefuses(rel) &&
|
|
2583
|
+
olderHubReason !== null &&
|
|
2265
2584
|
isFilePlaneClass(
|
|
2266
2585
|
classifyProjectFile(rel, {
|
|
2267
2586
|
canvasGroups: opts.canvasGroups,
|
|
@@ -2273,29 +2592,54 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
2273
2592
|
!(
|
|
2274
2593
|
kept?.state === 'refused' &&
|
|
2275
2594
|
kept.blockedClass === 'refused' &&
|
|
2276
|
-
kept.reason ===
|
|
2595
|
+
kept.reason === olderHubReason &&
|
|
2277
2596
|
kept.refusedHash === undefined
|
|
2278
2597
|
)
|
|
2279
2598
|
) {
|
|
2280
2599
|
ledger.setState(rel, 'refused', {
|
|
2281
|
-
reason:
|
|
2600
|
+
reason: olderHubReason,
|
|
2282
2601
|
blockedClass: 'refused',
|
|
2283
2602
|
refusedHash: undefined,
|
|
2284
2603
|
});
|
|
2285
2604
|
}
|
|
2286
|
-
out.dropped.push({ rel, reason:
|
|
2605
|
+
out.dropped.push({ rel, reason: olderHubReason });
|
|
2287
2606
|
continue;
|
|
2288
2607
|
}
|
|
2289
2608
|
|
|
2609
|
+
// AN ANSWER IS BEING CARRIED OUT, OR WAS GIVEN (issue #207, 7b). A held delete an owner purge
|
|
2610
|
+
// is deleting on the hub is left alone until it ends. A file the person kept on the hub stays
|
|
2611
|
+
// there and does not come back here — while the hub still holds the bytes this Mac last saw.
|
|
2612
|
+
// A new version from a teammate, a tombstone, or the file back on this disk decides as usual.
|
|
2613
|
+
if (!here && purgingDeletes.has(rel) && remoteHash !== null) continue;
|
|
2614
|
+
if (
|
|
2615
|
+
!here &&
|
|
2616
|
+
kept?.state === 'hub-only' &&
|
|
2617
|
+
remoteHash !== null &&
|
|
2618
|
+
remoteHash === (kept.syncedHash ?? kept.lastSeenHash ?? null)
|
|
2619
|
+
) {
|
|
2620
|
+
continue;
|
|
2621
|
+
}
|
|
2622
|
+
|
|
2623
|
+
// GONE FROM HERE, AND THE HUB HOLDS EXACTLY WHAT THIS MAC LAST SAW (issue #207). No recorded
|
|
2624
|
+
// ancestor — the upload landed while its answer was lost (a timeout on a slow link), or the
|
|
2625
|
+
// pass ended before adopting it — so this read as "the hub offers a file this machine has
|
|
2626
|
+
// never had" and the next pass downloaded the moved-out renders again. This Mac DID have
|
|
2627
|
+
// those bytes: it is a local delete, decided (and breaker-held) like any other. Only for
|
|
2628
|
+
// this decision — the ledger's ancestor moves only after bytes land (`adoptAfter`).
|
|
2629
|
+
const ancestor =
|
|
2630
|
+
ledger.ancestorOf(rel) ??
|
|
2631
|
+
(!here && remoteHash !== null && !row?.deleted && kept?.lastSeenHash === remoteHash
|
|
2632
|
+
? remoteHash
|
|
2633
|
+
: null);
|
|
2290
2634
|
const state: FileState = {
|
|
2291
2635
|
path: rel,
|
|
2292
2636
|
local: here?.hash ?? null,
|
|
2293
2637
|
remote: remoteHash,
|
|
2294
|
-
ancestor
|
|
2638
|
+
ancestor,
|
|
2295
2639
|
...(row?.deleted ? { remoteTombstone: true } : {}),
|
|
2296
2640
|
...(degraded ? { epochChanged: true } : {}),
|
|
2297
2641
|
...(remoteHash && ledger.outboxHas(remoteHash) ? { selfInFlight: true } : {}),
|
|
2298
|
-
...(
|
|
2642
|
+
...(propagateDeletes ? { propagateDeletes: true } : {}),
|
|
2299
2643
|
};
|
|
2300
2644
|
const decision = decideFile(state);
|
|
2301
2645
|
// REFUSED FOR GOOD, AND UNCHANGED (issue #175): the door already said no
|
|
@@ -2327,6 +2671,36 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
2327
2671
|
state: remoteHash !== null ? 'on-hub' : 'local-only',
|
|
2328
2672
|
});
|
|
2329
2673
|
out.synced += 1;
|
|
2674
|
+
} else if (
|
|
2675
|
+
decision.adoptAncestor &&
|
|
2676
|
+
!here &&
|
|
2677
|
+
(row?.deleted === true || ledger.remoteOf(rel) === null)
|
|
2678
|
+
) {
|
|
2679
|
+
// GONE ON BOTH SIDES (issue #207). Not here, and the hub SAID so — a tombstone on this
|
|
2680
|
+
// page, or a remembered one (a complete full read is the only other writer of `null`).
|
|
2681
|
+
// There is nothing left to move or to agree on, so nothing to track. The row stayed
|
|
2682
|
+
// behind instead, and a row with no state reads `local-only`: every file this Mac
|
|
2683
|
+
// deleted came back in Sync details as "only on this Mac" the pass its own tombstone
|
|
2684
|
+
// arrived (`noteRemote` re-creates a forgotten row). A remote never learned (`undefined`)
|
|
2685
|
+
// is not a statement, so that row keeps its ancestor for the next full read.
|
|
2686
|
+
ledger.forget(rel);
|
|
2687
|
+
purgingDeletes.delete(rel);
|
|
2688
|
+
confirmedDeletes.delete(rel);
|
|
2689
|
+
} else if (
|
|
2690
|
+
!here &&
|
|
2691
|
+
remoteHash !== null &&
|
|
2692
|
+
!propagateDeletes &&
|
|
2693
|
+
state.ancestor === remoteHash
|
|
2694
|
+
) {
|
|
2695
|
+
// 2.0.5 rule (a) — DELETED HERE, KEPT THERE, AND SAID SO. With delete
|
|
2696
|
+
// sync off this is a deliberate hold (no resurrection, no delete), but
|
|
2697
|
+
// the row still read `on-hub` from the pass that once delivered it:
|
|
2698
|
+
// the field ledger claimed 7 614 of 7 617 delivered while 1 814 of
|
|
2699
|
+
// those files were not on the disk. Held with a reason instead; a
|
|
2700
|
+
// copy that comes back with the same bytes is agreement again.
|
|
2701
|
+
if (!(kept?.state === 'stuck' && kept.reason === DELETED_HERE_HELD_REASON)) {
|
|
2702
|
+
ledger.setState(rel, 'stuck', { reason: DELETED_HERE_HELD_REASON });
|
|
2703
|
+
}
|
|
2330
2704
|
}
|
|
2331
2705
|
continue;
|
|
2332
2706
|
}
|
|
@@ -2364,8 +2738,17 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
2364
2738
|
|
|
2365
2739
|
for (const direction of ['out', 'in'] as const) {
|
|
2366
2740
|
const action = direction === 'out' ? 'propagate-delete' : 'quarantine';
|
|
2367
|
-
|
|
2368
|
-
|
|
2741
|
+
// Issue #207 (7b) — a held delete the person confirmed goes through (the hub's door still
|
|
2742
|
+
// gates it). One still waiting for an answer keeps waiting, and a new local delete joins its
|
|
2743
|
+
// question rather than slipping out under the limit beside it.
|
|
2744
|
+
const hits = work.filter(
|
|
2745
|
+
(w) => w.decision.action === action && !(direction === 'out' && confirmedDeletes.has(w.rel))
|
|
2746
|
+
);
|
|
2747
|
+
const asking =
|
|
2748
|
+
direction === 'out' &&
|
|
2749
|
+
opts.unlimitedOutboundDeletes !== true &&
|
|
2750
|
+
hits.some((w) => ledger.row(w.rel)?.state === 'delete-held');
|
|
2751
|
+
if (hits.length === 0 || !(asking || overBreaker(direction, hits.length))) continue;
|
|
2369
2752
|
const paths = hits.map((w) => w.rel).sort();
|
|
2370
2753
|
// ONCE PER DISTINCT HOLD, not once per pass.
|
|
2371
2754
|
//
|
|
@@ -2381,14 +2764,28 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
2381
2764
|
? `[sync/files] ${paths.length} of ${tracked} tracked files are gone from this machine — NOT telling the project. If that was a branch switch or a bad restore, nothing is lost; if you meant it, confirm the deletion.`
|
|
2382
2765
|
: `[sync/files] the project wants to remove ${paths.length} of ${tracked} tracked files here — holding. Nothing was deleted.`
|
|
2383
2766
|
);
|
|
2384
|
-
out.deleteHeld = { direction, count: paths.length, paths: paths.slice(0, 200) };
|
|
2385
2767
|
for (const w of hits) {
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
}
|
|
2768
|
+
if (direction === 'out') {
|
|
2769
|
+
// Its own state (7b): `conflict` read as "stuck" and offered no answer.
|
|
2770
|
+
if (ledger.row(w.rel)?.state !== 'delete-held') {
|
|
2771
|
+
ledger.setState(w.rel, 'delete-held', { reason: DELETE_HELD_REASON });
|
|
2772
|
+
}
|
|
2773
|
+
} else {
|
|
2774
|
+
ledger.setState(w.rel, 'conflict', {
|
|
2775
|
+
reason: 'the project wants this removed, as part of a batch too large to apply unasked',
|
|
2776
|
+
});
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
if (direction === 'out') {
|
|
2780
|
+
const all = summarizeHeldDeletes(ledger.rows());
|
|
2781
|
+
out.deleteHeld = {
|
|
2782
|
+
direction,
|
|
2783
|
+
count: all.count,
|
|
2784
|
+
paths: all.paths.slice(0, 200),
|
|
2785
|
+
folders: all.folders.slice(0, 20),
|
|
2786
|
+
};
|
|
2787
|
+
} else {
|
|
2788
|
+
out.deleteHeld = { direction, count: paths.length, paths: paths.slice(0, 200) };
|
|
2392
2789
|
}
|
|
2393
2790
|
work = work.filter((w) => !hits.includes(w));
|
|
2394
2791
|
}
|
|
@@ -2428,6 +2825,11 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
2428
2825
|
work = work.filter((w) => !firstAnchor.includes(w));
|
|
2429
2826
|
}
|
|
2430
2827
|
|
|
2828
|
+
// A LONG RUN OF PICTURES IN ONE FOLDER (issue #207) — a render sequence, a frame dump. They
|
|
2829
|
+
// sync like everything else; the panel only says so, and offers to leave the folder out.
|
|
2830
|
+
const sequences = largeSequences(work);
|
|
2831
|
+
if (sequences.length > 0) out.largeSequences = sequences;
|
|
2832
|
+
|
|
2431
2833
|
// ── 4. Apply ─────────────────────────────────────────────────────────
|
|
2432
2834
|
//
|
|
2433
2835
|
// The open canvas first (#204): its own files, imports and assets are what a person is looking
|
|
@@ -2936,6 +3338,16 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
2936
3338
|
out.dropped.push({ rel, reason: res.reason });
|
|
2937
3339
|
return true;
|
|
2938
3340
|
}
|
|
3341
|
+
if (res.gone) {
|
|
3342
|
+
// ISSUE #207 — THE FILE LEFT THIS MAC between the scan and its upload (6 555 renders
|
|
3343
|
+
// moved out mid-pass: 951 ENOENT retries every 5 s). Not a failure and not a backoff:
|
|
3344
|
+
// the upload is cancelled and the row leaves the queue. The next pass reads the
|
|
3345
|
+
// absence — nothing if the hub never had it, a delete proposal if it did.
|
|
3346
|
+
ledger.noteAttemptOk(rel);
|
|
3347
|
+
ledger.setState(rel, 'local-only', { reason: 'no longer on this Mac' });
|
|
3348
|
+
out.gone = (out.gone ?? 0) + 1;
|
|
3349
|
+
return false;
|
|
3350
|
+
}
|
|
2939
3351
|
out.failed.push({ rel, reason: res.reason });
|
|
2940
3352
|
ledger.setState(rel, 'stuck', { reason: res.reason });
|
|
2941
3353
|
return false;
|
|
@@ -2984,7 +3396,7 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
2984
3396
|
out.conflicts.push({ rel, copy: copyRel });
|
|
2985
3397
|
// The copy travels too, so BOTH ends see the conflict rather than only
|
|
2986
3398
|
// the machine that happened to lose.
|
|
2987
|
-
const copyLocal = statLocal(copyRel);
|
|
3399
|
+
const copyLocal = await statLocal(copyRel);
|
|
2988
3400
|
if (copyLocal) {
|
|
2989
3401
|
const res = await push(copyLocal, null);
|
|
2990
3402
|
if (res.ok) out.pushed.push(copyRel);
|
|
@@ -3023,8 +3435,11 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
3023
3435
|
// Gone here, and the hub still holds exactly what we last reconciled —
|
|
3024
3436
|
// the Syncthing rule. The CAS carries our ancestor, so an edit that
|
|
3025
3437
|
// landed in between wins and this comes back as a conflict instead.
|
|
3026
|
-
|
|
3438
|
+
// No recorded ancestor (issue #207): the hub hash this Mac last saw here is the CAS — the
|
|
3439
|
+
// decision above only got here because the two were equal.
|
|
3440
|
+
const res = await pushDelete(rel, ledger.ancestorOf(rel) ?? remoteHash);
|
|
3027
3441
|
if (res.ok) {
|
|
3442
|
+
confirmedDeletes.delete(rel);
|
|
3028
3443
|
ledger.forget(rel);
|
|
3029
3444
|
out.deleted.push({ rel, parked: null });
|
|
3030
3445
|
return true;
|
|
@@ -3059,11 +3474,11 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
3059
3474
|
}
|
|
3060
3475
|
}
|
|
3061
3476
|
|
|
3062
|
-
function statLocal(rel: string): SyncableLocalFile | null {
|
|
3477
|
+
async function statLocal(rel: string): Promise<SyncableLocalFile | null> {
|
|
3063
3478
|
const abs = path.join(designRoot, rel);
|
|
3064
3479
|
try {
|
|
3065
3480
|
const st = statSync(abs);
|
|
3066
|
-
const hash =
|
|
3481
|
+
const hash = await hashFileStreamed(abs);
|
|
3067
3482
|
return { rel, abs, hash, size: st.size, mtimeMs: st.mtimeMs, cls: 'inert-media' };
|
|
3068
3483
|
} catch {
|
|
3069
3484
|
return null;
|
|
@@ -3090,6 +3505,27 @@ export function createFilePlane(opts: FilePlaneOptions): FilePlane {
|
|
|
3090
3505
|
dorucekaTotal() {
|
|
3091
3506
|
return Object.keys(ledger.rows()).length;
|
|
3092
3507
|
},
|
|
3508
|
+
heldDeletes() {
|
|
3509
|
+
// What still waits for an answer: an answered row (being sent, or purged) is not asked again.
|
|
3510
|
+
const waiting: Record<string, LedgerRow> = {};
|
|
3511
|
+
for (const [rel, row] of Object.entries(ledger.rows()))
|
|
3512
|
+
if (!purgingDeletes.has(rel) && !confirmedDeletes.has(rel)) waiting[rel] = row;
|
|
3513
|
+
return summarizeHeldDeletes(waiting);
|
|
3514
|
+
},
|
|
3515
|
+
answerHeldDeletes(how, folder) {
|
|
3516
|
+
const rels = summarizeHeldDeletes(ledger.rows()).paths.filter(
|
|
3517
|
+
(r) => inHeldFolder(r, folder) && !purgingDeletes.has(r) && !confirmedDeletes.has(r)
|
|
3518
|
+
);
|
|
3519
|
+
for (const rel of rels) {
|
|
3520
|
+
if (how === 'send') confirmedDeletes.add(rel);
|
|
3521
|
+
else if (how === 'purging') purgingDeletes.add(rel);
|
|
3522
|
+
else ledger.setState(rel, 'hub-only', { reason: HUB_ONLY_REASON });
|
|
3523
|
+
}
|
|
3524
|
+
return rels;
|
|
3525
|
+
},
|
|
3526
|
+
endPurge(rels) {
|
|
3527
|
+
for (const rel of rels) purgingDeletes.delete(rel);
|
|
3528
|
+
},
|
|
3093
3529
|
/**
|
|
3094
3530
|
* HOW MUCH MEDIA IS NOT HERE — plan T29.
|
|
3095
3531
|
*
|