cursedbelt-server 4.51.0 → 4.52.0
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.
|
@@ -46,6 +46,14 @@ export interface DroppedFile {
|
|
|
46
46
|
ext: string;
|
|
47
47
|
size: number;
|
|
48
48
|
mtimeMs: number;
|
|
49
|
+
/**
|
|
50
|
+
* The inode and the change time, from the same `stat` as `size` — what tells a file that was
|
|
51
|
+
* REPLACED from one that kept its name and size (collections' linked ledger keys on it, forge
|
|
52
|
+
* task 3585). Optional only so a handler's test can build a `DroppedFile` without them; the walk
|
|
53
|
+
* always sets both.
|
|
54
|
+
*/
|
|
55
|
+
ino?: number;
|
|
56
|
+
ctimeMs?: number;
|
|
49
57
|
/** Every other FILE name in the same directory — see {@link ScanOptions.captureSiblings}. */
|
|
50
58
|
siblings: string[];
|
|
51
59
|
/**
|
|
@@ -126,6 +134,13 @@ export interface ScanOptions {
|
|
|
126
134
|
* — an app's quarantine or `done/`, a name that is the owner's own inside a linked folder.
|
|
127
135
|
*/
|
|
128
136
|
skipTopDirs?: readonly string[];
|
|
137
|
+
/**
|
|
138
|
+
* Skip every directory whose name starts with a dot, at any depth — another tool's state, never
|
|
139
|
+
* content. Matters most with {@link followLinks}: a link to a whole drive would otherwise walk its
|
|
140
|
+
* `.Spotlight-V100`, `.fseventsd` and `.Trashes`. Off by default, so no consumer changes
|
|
141
|
+
* behavior unasked.
|
|
142
|
+
*/
|
|
143
|
+
skipHiddenDirs?: boolean;
|
|
129
144
|
/**
|
|
130
145
|
* Walk THROUGH symlinks: a linked folder is ingested in place (`links.ts`). Off by default, so
|
|
131
146
|
* no consumer changes behavior unasked. See {@link walkDropzone}.
|
|
@@ -97,6 +97,8 @@ export async function walkDropzone(root, opts = {}) {
|
|
|
97
97
|
ext: extOf(name),
|
|
98
98
|
size: info.size,
|
|
99
99
|
mtimeMs: info.mtimeMs,
|
|
100
|
+
ino: info.ino,
|
|
101
|
+
ctimeMs: info.ctimeMs,
|
|
100
102
|
siblings,
|
|
101
103
|
...(linked ? { linked: { realPath: await realpath(path) } } : {}),
|
|
102
104
|
});
|
|
@@ -152,6 +154,8 @@ export async function walkDropzone(root, opts = {}) {
|
|
|
152
154
|
if (isDir) {
|
|
153
155
|
if (skip.has(entry.name))
|
|
154
156
|
continue;
|
|
157
|
+
if (opts.skipHiddenDirs && entry.name.startsWith("."))
|
|
158
|
+
continue;
|
|
155
159
|
if (dir === root && namedIn(opts.skipTopDirs, entry.name))
|
|
156
160
|
continue;
|
|
157
161
|
if (!(await firstVisit(path)))
|
package/docs/skipped-tests.md
CHANGED
|
@@ -16,4 +16,5 @@ carrying one goes red until it is removed. Inherited from `cursedbelt` at the
|
|
|
16
16
|
| `src/server/storage/imageThumbnail.spec.ts` | `ffmpeg` on `PATH` |
|
|
17
17
|
| `src/server/storage/videoProcessor.posterOnly.spec.ts` | `ffmpeg` on `PATH` |
|
|
18
18
|
| `src/server/storage/files/adapter.photo.display.spec.ts` | `ffmpeg` on `PATH` |
|
|
19
|
+
| `src/server/dropzone/links.spec.ts` | macOS — a real Finder alias is written and resolved through `osascript` and Foundation; runs on every `bun run test` on this Mac (green 2026-10-26) |
|
|
19
20
|
| `src/server/storage/fileUploadClient-chunked.integration.spec.ts` | a real `binary-server` checkout — set `BINARY_SERVER_DIR` to its path (`apps/binary-server` in this generation). No default by design: a published package must not go looking in one machine's directory layout. Moved here from `cursedbelt` at the 2026-09-15 split, with the storage internals it drives. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cursedbelt-server",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.52.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "The app-facing Bun/Hono server tier of the cursedbelt split — storage, sharing, activity, guard, sync. React-free; cursedbelt-core below it.",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
-
import { existsSync, lstatSync, mkdirSync, mkdtempSync, readlinkSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { existsSync, lstatSync, mkdirSync, mkdtempSync, readlinkSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
-
import { adoptFinderAliases, DROPZONE_LINK, ensureDropzoneLink, isFinderAlias, linkSource } from "./links.js";
|
|
5
|
+
import { adoptFinderAliases, DROPZONE_LINK, ensureDropzoneLink, isFinderAlias, isMountPoint, linkedRoomBytes, linkSource, resolveFinderAlias } from "./links.js";
|
|
6
6
|
import { scanDropzone, sweepDropzone, walkDropzone, type DropOutcome } from "./scan.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -92,6 +92,24 @@ describe("walkDropzone with followLinks", () => {
|
|
|
92
92
|
const { files } = await walkDropzone(root, { followLinks: true, skipTopDirs: ["dups"] });
|
|
93
93
|
expect(files.map((f) => f.relativePath)).toEqual(["Drive/dups/y.mp3"]);
|
|
94
94
|
});
|
|
95
|
+
|
|
96
|
+
test("skipHiddenDirs leaves another tool's state alone at every depth — a linked drive's `.Spotlight-V100` too (forge task 3754)", async () => {
|
|
97
|
+
write(join(root, ".cache", "x.mp3"));
|
|
98
|
+
write(join(drive, ".Spotlight-V100", "store.db"));
|
|
99
|
+
write(join(drive, "Album", "a.mp3"));
|
|
100
|
+
symlinkSync(drive, join(root, "Drive"));
|
|
101
|
+
const asked = await walkDropzone(root, { followLinks: true, skipHiddenDirs: true });
|
|
102
|
+
expect(asked.files.map((f) => f.relativePath)).toEqual(["Drive/Album/a.mp3"]);
|
|
103
|
+
// Off by default: no consumer changes behavior unasked.
|
|
104
|
+
expect((await walkDropzone(root, { followLinks: true })).files).toHaveLength(3);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test("each file carries its inode and change time, from the one stat — a replaced file is told from a kept one", async () => {
|
|
108
|
+
const at = write(join(drive, "a.mp3"));
|
|
109
|
+
symlinkSync(drive, join(root, "Drive"));
|
|
110
|
+
const [file] = (await walkDropzone(root, { followLinks: true })).files;
|
|
111
|
+
expect(file).toMatchObject({ ino: statSync(at).ino, ctimeMs: statSync(at).ctimeMs });
|
|
112
|
+
});
|
|
95
113
|
});
|
|
96
114
|
|
|
97
115
|
describe("sweepDropzone never deletes a linked file", () => {
|
|
@@ -143,6 +161,24 @@ describe("Finder aliases", () => {
|
|
|
143
161
|
expect(lstatSync(join(root, "done", "old alias")).isFile()).toBe(true);
|
|
144
162
|
});
|
|
145
163
|
|
|
164
|
+
// Waiting for macOS: skipped elsewhere, because only osascript and Foundation write and resolve a real alias.
|
|
165
|
+
test.skipIf(process.platform !== "darwin")("🔴 a REAL alias becomes a symlink to its target — headless, through Foundation (from collections, forge task 3754)", async () => {
|
|
166
|
+
const at = join(root, "Videos", "tod alias");
|
|
167
|
+
mkdirSync(join(root, "Videos"));
|
|
168
|
+
// Written through Foundation the way Finder writes one.
|
|
169
|
+
const script =
|
|
170
|
+
'function run(argv){ObjC.import("Foundation");const t=$.NSURL.fileURLWithPath(argv[0]);' +
|
|
171
|
+
"const d=t.bookmarkDataWithOptionsIncludingResourceValuesForKeysRelativeToURLError(1<<10,$(),$(),null);" +
|
|
172
|
+
"return $.NSURL.writeBookmarkDataToURLOptionsError(d,$.NSURL.fileURLWithPath(argv[1]),1<<10,null);}";
|
|
173
|
+
const child = Bun.spawn(["osascript", "-l", "JavaScript", "-e", script, drive, at], { stdout: "ignore", stderr: "pipe" });
|
|
174
|
+
if ((await child.exited) !== 0) throw new Error(await new Response(child.stderr).text());
|
|
175
|
+
expect(resolveFinderAlias(at)).toBe(realpathSync(drive));
|
|
176
|
+
|
|
177
|
+
expect(await adoptFinderAliases(root)).toEqual({ linked: [`Videos/tod alias → ${realpathSync(drive)}`], unresolved: [] });
|
|
178
|
+
expect(lstatSync(at).isSymbolicLink()).toBe(true);
|
|
179
|
+
expect(readlinkSync(at)).toBe(realpathSync(drive));
|
|
180
|
+
});
|
|
181
|
+
|
|
146
182
|
test("a dry run says what it would do and changes nothing", async () => {
|
|
147
183
|
alias(join(root, "tod alias"));
|
|
148
184
|
const result = await adoptFinderAliases(root, { dryRun: true, resolve: () => drive });
|
|
@@ -157,6 +193,16 @@ describe("linkSource and the link beside the code", () => {
|
|
|
157
193
|
expect(linkSource("/Volumes/X/a", () => true).state).toBe("deleted");
|
|
158
194
|
expect(linkSource("/Volumes/X/a", () => false)).toEqual({ state: "unmounted", target: "/Volumes/X/a", volume: "/Volumes/X" });
|
|
159
195
|
expect(linkSource(join(base, "gone")).state).toBe("deleted");
|
|
196
|
+
// A plain folder — what macOS can leave in /Volumes after an unclean eject — is not a mount point.
|
|
197
|
+
expect(isMountPoint(drive)).toBe(false);
|
|
198
|
+
expect(isMountPoint("/")).toBe(false);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
test("linkedRoomBytes is what statfs says minus the floor and what is owed; a store that is not there holds nothing back", () => {
|
|
202
|
+
const room = linkedRoomBytes(base);
|
|
203
|
+
expect(typeof room).toBe("number");
|
|
204
|
+
expect(linkedRoomBytes(base, 1024)).toBe((room as number) - 1024);
|
|
205
|
+
expect(linkedRoomBytes(join(base, "no", "such", "store"))).toBeNull();
|
|
160
206
|
});
|
|
161
207
|
|
|
162
208
|
test("ensureDropzoneLink makes the folder and the link, is quiet when right, and never replaces a real file", async () => {
|
|
@@ -167,6 +213,9 @@ describe("linkSource and the link beside the code", () => {
|
|
|
167
213
|
expect(readlinkSync(join(app, DROPZONE_LINK))).toBe(target);
|
|
168
214
|
expect(existsSync(target)).toBe(true);
|
|
169
215
|
expect(await ensureDropzoneLink(app, target)).toBeNull();
|
|
216
|
+
const moved = join(base, "state", "moved");
|
|
217
|
+
expect(await ensureDropzoneLink(app, moved)).toContain("linked");
|
|
218
|
+
expect(readlinkSync(join(app, DROPZONE_LINK))).toBe(moved);
|
|
170
219
|
|
|
171
220
|
const other = join(base, "other");
|
|
172
221
|
mkdirSync(other);
|
|
@@ -51,6 +51,14 @@ export interface DroppedFile {
|
|
|
51
51
|
ext: string;
|
|
52
52
|
size: number;
|
|
53
53
|
mtimeMs: number;
|
|
54
|
+
/**
|
|
55
|
+
* The inode and the change time, from the same `stat` as `size` — what tells a file that was
|
|
56
|
+
* REPLACED from one that kept its name and size (collections' linked ledger keys on it, forge
|
|
57
|
+
* task 3585). Optional only so a handler's test can build a `DroppedFile` without them; the walk
|
|
58
|
+
* always sets both.
|
|
59
|
+
*/
|
|
60
|
+
ino?: number;
|
|
61
|
+
ctimeMs?: number;
|
|
54
62
|
/** Every other FILE name in the same directory — see {@link ScanOptions.captureSiblings}. */
|
|
55
63
|
siblings: string[];
|
|
56
64
|
/**
|
|
@@ -114,6 +122,13 @@ export interface ScanOptions {
|
|
|
114
122
|
* — an app's quarantine or `done/`, a name that is the owner's own inside a linked folder.
|
|
115
123
|
*/
|
|
116
124
|
skipTopDirs?: readonly string[];
|
|
125
|
+
/**
|
|
126
|
+
* Skip every directory whose name starts with a dot, at any depth — another tool's state, never
|
|
127
|
+
* content. Matters most with {@link followLinks}: a link to a whole drive would otherwise walk its
|
|
128
|
+
* `.Spotlight-V100`, `.fseventsd` and `.Trashes`. Off by default, so no consumer changes
|
|
129
|
+
* behavior unasked.
|
|
130
|
+
*/
|
|
131
|
+
skipHiddenDirs?: boolean;
|
|
117
132
|
/**
|
|
118
133
|
* Walk THROUGH symlinks: a linked folder is ingested in place (`links.ts`). Off by default, so
|
|
119
134
|
* no consumer changes behavior unasked. See {@link walkDropzone}.
|
|
@@ -208,6 +223,8 @@ export async function walkDropzone(root: string, opts: ScanOptions = {}): Promis
|
|
|
208
223
|
ext: extOf(name),
|
|
209
224
|
size: info.size,
|
|
210
225
|
mtimeMs: info.mtimeMs,
|
|
226
|
+
ino: info.ino,
|
|
227
|
+
ctimeMs: info.ctimeMs,
|
|
211
228
|
siblings,
|
|
212
229
|
...(linked ? { linked: { realPath: await realpath(path) } } : {}),
|
|
213
230
|
});
|
|
@@ -258,6 +275,7 @@ export async function walkDropzone(root: string, opts: ScanOptions = {}): Promis
|
|
|
258
275
|
}
|
|
259
276
|
if (isDir) {
|
|
260
277
|
if (skip.has(entry.name)) continue;
|
|
278
|
+
if (opts.skipHiddenDirs && entry.name.startsWith(".")) continue;
|
|
261
279
|
if (dir === root && namedIn(opts.skipTopDirs, entry.name)) continue;
|
|
262
280
|
if (!(await firstVisit(path))) continue;
|
|
263
281
|
await walk(path, viaLink);
|