@ai-ecoverse/slicc-kernel 1.196.43 → 1.196.45
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 +1 -1
- package/dist/async-process.js +1 -1
- package/dist/cloudflare-sources.js +1 -1
- package/dist/cloudflare.js +158 -63
- package/dist/cloudflare.js.map +4 -4
- package/dist/kernel-worker.js +158 -63
- package/dist/kernel-worker.js.map +4 -4
- package/dist/meta.js.map +2 -2
- package/dist/node-process-worker.cjs +1 -1
- package/dist/node-process-worker.js +1 -1
- package/dist/node.js +158 -63
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +1 -1
- package/dist/types/fs/meta.d.ts +3 -0
- package/dist/types/fs/opfs.d.ts +2 -0
- package/dist/types/fs/rename-cleanup.d.ts +1 -1
- package/dist/types/fs/rename-manifest.d.ts +16 -0
- package/package.json +2 -2
package/dist/cloudflare.js
CHANGED
|
@@ -5309,7 +5309,7 @@ function satisfies(version, range2) {
|
|
|
5309
5309
|
}
|
|
5310
5310
|
|
|
5311
5311
|
// src/version.ts
|
|
5312
|
-
var KERNEL_VERSION = true ? "1.196.
|
|
5312
|
+
var KERNEL_VERSION = true ? "1.196.45" : "0.0.0-dev";
|
|
5313
5313
|
var OS_RELEASE = "6.0.0-slicc";
|
|
5314
5314
|
function procVersion() {
|
|
5315
5315
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -33934,9 +33934,9 @@ async function copiedEntry(handle, path, file) {
|
|
|
33934
33934
|
function absent(err) {
|
|
33935
33935
|
return err.name === "NotFoundError";
|
|
33936
33936
|
}
|
|
33937
|
-
async function removeOne(parent, name2, rest2,
|
|
33937
|
+
async function removeOne(parent, name2, rest2, lookup2, signal) {
|
|
33938
33938
|
signal?.throwIfAborted();
|
|
33939
|
-
const entry =
|
|
33939
|
+
const entry = await lookup2(rest2);
|
|
33940
33940
|
if (!entry) return;
|
|
33941
33941
|
try {
|
|
33942
33942
|
const handle = entry.kind === "file" ? await parent.getFileHandle(name2) : await parent.getDirectoryHandle(name2);
|
|
@@ -33946,7 +33946,7 @@ async function removeOne(parent, name2, rest2, entries, signal) {
|
|
|
33946
33946
|
if (file.lastModified !== entry.mtime || file.size !== entry.size) return;
|
|
33947
33947
|
} else {
|
|
33948
33948
|
for await (const child2 of handle.keys())
|
|
33949
|
-
await removeOne(handle, child2, rest2 + "/" + child2,
|
|
33949
|
+
await removeOne(handle, child2, rest2 + "/" + child2, lookup2, signal);
|
|
33950
33950
|
}
|
|
33951
33951
|
signal?.throwIfAborted();
|
|
33952
33952
|
await parent.removeEntry(name2);
|
|
@@ -33954,10 +33954,64 @@ async function removeOne(parent, name2, rest2, entries, signal) {
|
|
|
33954
33954
|
if (!absent(err) && err.name !== "TypeMismatchError") throw err;
|
|
33955
33955
|
}
|
|
33956
33956
|
}
|
|
33957
|
-
function removeCopied(parent, name2, manifest, signal) {
|
|
33958
|
-
|
|
33957
|
+
function removeCopied(parent, name2, manifest, signal, overflow) {
|
|
33958
|
+
const entries = new Map(manifest.map((entry) => [entry.path, entry]));
|
|
33959
|
+
return removeOne(parent, name2, "", (path) => entries.get(path) ?? overflow?.(path), signal);
|
|
33959
33960
|
}
|
|
33960
33961
|
|
|
33962
|
+
// src/fs/rename-manifest.ts
|
|
33963
|
+
var INLINE_BYTES = 256 * 1024;
|
|
33964
|
+
var BATCH = 64;
|
|
33965
|
+
function manifestRoot(intent) {
|
|
33966
|
+
return "rename-manifest:" + intent;
|
|
33967
|
+
}
|
|
33968
|
+
async function storedStamp(meta, intent, path) {
|
|
33969
|
+
const [row] = await meta.get([manifestRoot(intent) + path]);
|
|
33970
|
+
return row?.copyStamp && { path, ...row.copyStamp };
|
|
33971
|
+
}
|
|
33972
|
+
var RenameManifest = class {
|
|
33973
|
+
meta;
|
|
33974
|
+
intent;
|
|
33975
|
+
entries = [];
|
|
33976
|
+
pending = [];
|
|
33977
|
+
bytes = 2;
|
|
33978
|
+
indexed = false;
|
|
33979
|
+
constructor(meta, intent) {
|
|
33980
|
+
this.meta = meta;
|
|
33981
|
+
this.intent = intent;
|
|
33982
|
+
}
|
|
33983
|
+
async record(entry) {
|
|
33984
|
+
if (!this.indexed) {
|
|
33985
|
+
this.bytes += storedSize(JSON.stringify(entry)) + 1;
|
|
33986
|
+
if (this.bytes <= INLINE_BYTES) {
|
|
33987
|
+
this.entries.push(entry);
|
|
33988
|
+
return;
|
|
33989
|
+
}
|
|
33990
|
+
this.indexed = true;
|
|
33991
|
+
}
|
|
33992
|
+
const { path: relative2, ...copyStamp } = entry;
|
|
33993
|
+
const path = manifestRoot(this.intent) + relative2;
|
|
33994
|
+
this.pending.push({ path, change: () => ({ path, copyStamp }) });
|
|
33995
|
+
if (this.pending.length === BATCH) await this.flush();
|
|
33996
|
+
}
|
|
33997
|
+
async flush() {
|
|
33998
|
+
if (!this.pending.length) return;
|
|
33999
|
+
if (this.meta.updateMany) await this.meta.updateMany(this.pending);
|
|
34000
|
+
else for (const { path, change } of this.pending) await this.meta.update(path, change);
|
|
34001
|
+
this.pending.length = 0;
|
|
34002
|
+
}
|
|
34003
|
+
async marker(to) {
|
|
34004
|
+
await this.flush();
|
|
34005
|
+
if (!this.entries.length && !this.indexed) return void 0;
|
|
34006
|
+
return {
|
|
34007
|
+
intent: this.intent,
|
|
34008
|
+
to,
|
|
34009
|
+
entries: this.entries,
|
|
34010
|
+
...this.indexed && { indexed: true }
|
|
34011
|
+
};
|
|
34012
|
+
}
|
|
34013
|
+
};
|
|
34014
|
+
|
|
33961
34015
|
// src/fs/opfs.ts
|
|
33962
34016
|
var S_IFDIR2 = 16384;
|
|
33963
34017
|
var S_IFREG3 = 32768;
|
|
@@ -34005,9 +34059,10 @@ var INTENT_POLL_MS = 5;
|
|
|
34005
34059
|
var SOURCE_RETRY_MS = 250;
|
|
34006
34060
|
var SOURCE_BACKOFF_MS = 1e3;
|
|
34007
34061
|
var Copies = class extends Map {
|
|
34008
|
-
|
|
34009
|
-
|
|
34010
|
-
|
|
34062
|
+
manifest;
|
|
34063
|
+
constructor(meta, intent) {
|
|
34064
|
+
super();
|
|
34065
|
+
if (intent) this.manifest = new RenameManifest(meta, intent);
|
|
34011
34066
|
}
|
|
34012
34067
|
};
|
|
34013
34068
|
function needsCopy(handle, swap) {
|
|
@@ -35769,12 +35824,12 @@ var OpfsFs = class {
|
|
|
35769
35824
|
return this.privateCopy(source, parent, destination, target?.handle, moving);
|
|
35770
35825
|
const place = async () => {
|
|
35771
35826
|
this.forget(destination);
|
|
35772
|
-
const
|
|
35773
|
-
const root = { ino: inodeOf(source.path), ...moving };
|
|
35827
|
+
const root = { ino: sourceStat.ino, ...moving };
|
|
35774
35828
|
const owned4 = lock ? { lock } : {};
|
|
35775
35829
|
hooks.notify?.();
|
|
35776
35830
|
const first = copying ? await this.intend({ from: source.path, to: staged2, root, ...owned4 }) : void 0;
|
|
35777
35831
|
const second = copying && swap ? await this.intend({ from: staged2, to: destination, replace: true, root, ...owned4 }) : void 0;
|
|
35832
|
+
const copies = new Copies(this.meta, first);
|
|
35778
35833
|
await hooks.started?.().catch(async (err) => {
|
|
35779
35834
|
for (const intent of [first, second]) {
|
|
35780
35835
|
if (intent) await this.meta.update(intent, () => void 0);
|
|
@@ -35790,21 +35845,21 @@ var OpfsFs = class {
|
|
|
35790
35845
|
});
|
|
35791
35846
|
if (swap) await PLAIN3.rm.call(this, destination);
|
|
35792
35847
|
if (second) await this.intend({ from: staged2, to: destination, root, ...owned4 }, second);
|
|
35793
|
-
left.copyCommit = copies.marker(
|
|
35848
|
+
left.copyCommit = await copies.manifest?.marker(destination);
|
|
35794
35849
|
await this.meta.move(source.path, destination, carry, left);
|
|
35795
35850
|
this.movePending(source.path, destination);
|
|
35796
35851
|
if (!moved3 && first)
|
|
35797
|
-
await this.releaseSource(first, source.path, destination, left.ino, lock
|
|
35798
|
-
else if (first) await this.
|
|
35799
|
-
if (swap) {
|
|
35852
|
+
await this.releaseSource(first, source.path, destination, left.ino, lock);
|
|
35853
|
+
else if (first) await this.retireIntent(first);
|
|
35854
|
+
if (swap && second) {
|
|
35800
35855
|
const hidden = await dir.getDirectoryHandle(staging);
|
|
35801
|
-
copies.
|
|
35856
|
+
copies.manifest = new RenameManifest(this.meta, second);
|
|
35802
35857
|
const placed = await this.place(hidden, dir, name2, copies, copying);
|
|
35803
|
-
if (!placed
|
|
35804
|
-
const mark = vacatedAt(staged2, copies.marker(
|
|
35858
|
+
if (!placed) {
|
|
35859
|
+
const mark = vacatedAt(staged2, await copies.manifest.marker(destination));
|
|
35805
35860
|
await this.meta.update(staged2, () => mark);
|
|
35806
|
-
await this.releaseSource(second, staged2, destination, mark.ino, lock
|
|
35807
|
-
} else
|
|
35861
|
+
await this.releaseSource(second, staged2, destination, mark.ino, lock);
|
|
35862
|
+
} else await this.retireIntent(second);
|
|
35808
35863
|
}
|
|
35809
35864
|
await this.restamp(destination, copies);
|
|
35810
35865
|
this.changed(source.path, destination);
|
|
@@ -36186,7 +36241,6 @@ var OpfsFs = class {
|
|
|
36186
36241
|
const handle = source.handle;
|
|
36187
36242
|
const dir = parent.handle;
|
|
36188
36243
|
const name2 = baseOf4(to);
|
|
36189
|
-
const copies = new Copies();
|
|
36190
36244
|
const [entry] = await this.meta.get([source.path]);
|
|
36191
36245
|
const root = { ino: occupied(entry).ino ?? inodeOf(source.path), ...owner };
|
|
36192
36246
|
if (target?.kind === "directory" && movable(target) && movable(handle)) {
|
|
@@ -36196,14 +36250,23 @@ var OpfsFs = class {
|
|
|
36196
36250
|
if (await this.swapNative(source, dir, name2, target, emptyBackup, intent2)) {
|
|
36197
36251
|
this.forget(source.path);
|
|
36198
36252
|
this.forget(to);
|
|
36199
|
-
await this.commitPrivateCopy(
|
|
36253
|
+
await this.commitPrivateCopy(
|
|
36254
|
+
source.path,
|
|
36255
|
+
to,
|
|
36256
|
+
root,
|
|
36257
|
+
intent2,
|
|
36258
|
+
new Copies(this.meta, intent2),
|
|
36259
|
+
emptyBackup
|
|
36260
|
+
);
|
|
36200
36261
|
return;
|
|
36201
36262
|
}
|
|
36202
36263
|
}
|
|
36203
36264
|
await this.beforePrivateCopy?.();
|
|
36204
36265
|
const intent = await this.intend({ from: source.path, to, root, privateCopy: true });
|
|
36266
|
+
const copies = new Copies(this.meta, intent);
|
|
36205
36267
|
try {
|
|
36206
36268
|
await this.duplicate(handle, dir, name2, copies, "");
|
|
36269
|
+
await copies.manifest?.flush();
|
|
36207
36270
|
} catch (err) {
|
|
36208
36271
|
if (!target)
|
|
36209
36272
|
await dir.removeEntry(name2, { recursive: true }).catch((e) => {
|
|
@@ -36214,7 +36277,7 @@ var OpfsFs = class {
|
|
|
36214
36277
|
await target.removeEntry(child2, { recursive: true });
|
|
36215
36278
|
}
|
|
36216
36279
|
this.forget(to);
|
|
36217
|
-
await this.
|
|
36280
|
+
await this.retireIntent(intent);
|
|
36218
36281
|
throw translate(err, to, "write");
|
|
36219
36282
|
}
|
|
36220
36283
|
await this.commitPrivateCopy(source.path, to, root, intent, copies);
|
|
@@ -36241,7 +36304,7 @@ var OpfsFs = class {
|
|
|
36241
36304
|
const entries = await this.meta.get([from, to]);
|
|
36242
36305
|
let mark = entries[0];
|
|
36243
36306
|
if (!mark?.vacated || entries[1]?.ino !== ino) {
|
|
36244
|
-
mark = vacatedAt(from, copies.marker(
|
|
36307
|
+
mark = vacatedAt(from, await copies.manifest?.marker(to));
|
|
36245
36308
|
await this.meta.move(
|
|
36246
36309
|
from,
|
|
36247
36310
|
to,
|
|
@@ -36249,8 +36312,7 @@ var OpfsFs = class {
|
|
|
36249
36312
|
mark
|
|
36250
36313
|
);
|
|
36251
36314
|
}
|
|
36252
|
-
if (!emptyBackup)
|
|
36253
|
-
await this.releaseSource(intent, from, to, mark.ino, void 0, copies.remaining);
|
|
36315
|
+
if (!emptyBackup) await this.releaseSource(intent, from, to, mark.ino);
|
|
36254
36316
|
this.movePending(from, to);
|
|
36255
36317
|
await this.restamp(to, copies);
|
|
36256
36318
|
this.changed(from, to);
|
|
@@ -36272,22 +36334,45 @@ var OpfsFs = class {
|
|
|
36272
36334
|
}
|
|
36273
36335
|
return cleanupId(handle);
|
|
36274
36336
|
}
|
|
36275
|
-
|
|
36337
|
+
retireIntent(intent) {
|
|
36338
|
+
return this.meta.remove([intent, manifestRoot(intent)]);
|
|
36339
|
+
}
|
|
36340
|
+
async releaseSource(intent, from, to, id2, lock, unverified = false) {
|
|
36276
36341
|
this.syncSourceReservation(intent, from);
|
|
36277
|
-
const physicalSource = copiedEntries?.find((entry) => entry.path === "")?.id;
|
|
36278
36342
|
await this.intend(
|
|
36279
36343
|
{
|
|
36280
36344
|
from,
|
|
36281
36345
|
to,
|
|
36282
36346
|
sourceCleanup: id2,
|
|
36283
|
-
...
|
|
36284
|
-
...
|
|
36285
|
-
...copiedEntries && { copiedEntries }
|
|
36347
|
+
...unverified && { unverifiedSource: true },
|
|
36348
|
+
...lock && { lock }
|
|
36286
36349
|
},
|
|
36287
36350
|
intent
|
|
36288
36351
|
);
|
|
36289
36352
|
await this.cleanSource(intent, from, id2);
|
|
36290
36353
|
}
|
|
36354
|
+
async removeReserved(intent, from, reservation, rename, signal) {
|
|
36355
|
+
if (rename.unverifiedSource) {
|
|
36356
|
+
await this.sourceId(from);
|
|
36357
|
+
throw fsError("EBUSY", from);
|
|
36358
|
+
}
|
|
36359
|
+
const commit = reservation.copyCommit?.intent === intent ? reservation.copyCommit : void 0;
|
|
36360
|
+
const entries = commit?.entries ?? rename.copiedEntries;
|
|
36361
|
+
const expected = entries?.find((entry) => entry.path === "")?.id ?? rename.physicalSource;
|
|
36362
|
+
if (expected === void 0 || await this.sourceId(from) === expected) {
|
|
36363
|
+
const [dir, name2] = await this.parent(from);
|
|
36364
|
+
await this.inDir(dir, (parent) => {
|
|
36365
|
+
signal?.throwIfAborted();
|
|
36366
|
+
return entries ? removeCopied(
|
|
36367
|
+
parent,
|
|
36368
|
+
name2,
|
|
36369
|
+
entries,
|
|
36370
|
+
signal,
|
|
36371
|
+
commit?.indexed ? (path) => storedStamp(this.meta, intent, path) : void 0
|
|
36372
|
+
) : parent.removeEntry(name2);
|
|
36373
|
+
});
|
|
36374
|
+
}
|
|
36375
|
+
}
|
|
36291
36376
|
async cleanSource(intent, from, id2, signal) {
|
|
36292
36377
|
const remove = async () => {
|
|
36293
36378
|
if (signal?.aborted) return;
|
|
@@ -36296,14 +36381,7 @@ var OpfsFs = class {
|
|
|
36296
36381
|
const [reservation] = await (this.meta.fresh ?? this.meta.get).call(this.meta, [from]);
|
|
36297
36382
|
if (reservation?.vacated && reservation.ino === id2) {
|
|
36298
36383
|
try {
|
|
36299
|
-
|
|
36300
|
-
if (expected === void 0 || await this.sourceId(from) === expected) {
|
|
36301
|
-
const [dir, name2] = await this.parent(from);
|
|
36302
|
-
await this.inDir(dir, (parent) => {
|
|
36303
|
-
signal?.throwIfAborted();
|
|
36304
|
-
return current.rename?.copiedEntries ? removeCopied(parent, name2, current.rename.copiedEntries, signal) : parent.removeEntry(name2);
|
|
36305
|
-
});
|
|
36306
|
-
}
|
|
36384
|
+
await this.removeReserved(intent, from, reservation, current.rename, signal);
|
|
36307
36385
|
} catch (err) {
|
|
36308
36386
|
if (!missing5(err) && err.name !== "NotFoundError") return;
|
|
36309
36387
|
}
|
|
@@ -36312,7 +36390,7 @@ var OpfsFs = class {
|
|
|
36312
36390
|
(current2) => current2?.vacated && current2.ino === reservation.ino ? vacatedAt(from) : current2
|
|
36313
36391
|
);
|
|
36314
36392
|
}
|
|
36315
|
-
await this.
|
|
36393
|
+
await this.retireIntent(intent);
|
|
36316
36394
|
}
|
|
36317
36395
|
this.syncSourceReservation(intent);
|
|
36318
36396
|
};
|
|
@@ -36324,7 +36402,7 @@ var OpfsFs = class {
|
|
|
36324
36402
|
}
|
|
36325
36403
|
async duplicate(handle, parent, name2, copies, rest2) {
|
|
36326
36404
|
if (handle.kind === "file") return this.copyBytes(handle, parent, name2, { copies }, rest2);
|
|
36327
|
-
copies.
|
|
36405
|
+
await copies.manifest?.record(await copiedEntry(handle, rest2));
|
|
36328
36406
|
const dir = await this.io(parent.getDirectoryHandle(name2, { create: true }));
|
|
36329
36407
|
this.others++;
|
|
36330
36408
|
for await (const child2 of handle.values())
|
|
@@ -36333,24 +36411,27 @@ var OpfsFs = class {
|
|
|
36333
36411
|
hiddenBackups = /* @__PURE__ */ new Set();
|
|
36334
36412
|
pendingSources = /* @__PURE__ */ new Map();
|
|
36335
36413
|
retryAfter = /* @__PURE__ */ new Map();
|
|
36336
|
-
async retrySource(intent, from) {
|
|
36414
|
+
async retrySource(intent, from, mayClean, deadline) {
|
|
36337
36415
|
const now = performance.now();
|
|
36338
|
-
|
|
36339
|
-
|
|
36340
|
-
|
|
36416
|
+
if (now >= deadline) return false;
|
|
36417
|
+
const eligible = mayClean && now >= (this.retryAfter.get(intent) ?? -Infinity);
|
|
36418
|
+
let attempted = false;
|
|
36341
36419
|
if (eligible) this.retryAfter.set(intent, Infinity);
|
|
36342
36420
|
const controller = new AbortController();
|
|
36343
36421
|
const { promise, resolve: resolve2 } = Promise.withResolvers();
|
|
36344
36422
|
const timer = setTimeout(() => {
|
|
36345
36423
|
controller.abort();
|
|
36346
36424
|
resolve2();
|
|
36347
|
-
},
|
|
36425
|
+
}, deadline - now);
|
|
36348
36426
|
const retry = async () => {
|
|
36349
36427
|
const [entry] = await this.meta.under(intent);
|
|
36350
36428
|
controller.signal.throwIfAborted();
|
|
36351
36429
|
const id2 = entry?.rename?.sourceCleanup;
|
|
36352
36430
|
if (id2 === void 0) this.syncSourceReservation(intent);
|
|
36353
|
-
else if (eligible)
|
|
36431
|
+
else if (eligible) {
|
|
36432
|
+
attempted = true;
|
|
36433
|
+
await this.cleanSource(intent, from, id2, controller.signal);
|
|
36434
|
+
}
|
|
36354
36435
|
};
|
|
36355
36436
|
const attempt = retry().catch(nothing2).finally(() => {
|
|
36356
36437
|
clearTimeout(timer);
|
|
@@ -36358,6 +36439,7 @@ var OpfsFs = class {
|
|
|
36358
36439
|
this.retryAfter.set(intent, performance.now() + SOURCE_BACKOFF_MS);
|
|
36359
36440
|
});
|
|
36360
36441
|
await Promise.race([promise, attempt]);
|
|
36442
|
+
return attempted;
|
|
36361
36443
|
}
|
|
36362
36444
|
syncSourceReservation(intent, from) {
|
|
36363
36445
|
const path = from ?? this.pendingSources.get(intent);
|
|
@@ -36370,13 +36452,14 @@ var OpfsFs = class {
|
|
|
36370
36452
|
async reservedOp(name2, args) {
|
|
36371
36453
|
const touched = name2 === "symlink" ? args.slice(1, 2) : args.slice(0, PAIRED.has(name2) ? 2 : 1);
|
|
36372
36454
|
let attempted = false;
|
|
36455
|
+
let deadline;
|
|
36373
36456
|
for (const [intent, source] of this.pendingSources) {
|
|
36374
36457
|
if (!READS.includes(name2) && touched.some((p) => {
|
|
36375
36458
|
const at = normalizePath(p);
|
|
36376
36459
|
return within11(at, source) || REMOVALS2.has(name2) && (at === "/" || within11(source, at));
|
|
36377
36460
|
})) {
|
|
36378
|
-
|
|
36379
|
-
attempted = true;
|
|
36461
|
+
deadline ??= performance.now() + SOURCE_RETRY_MS;
|
|
36462
|
+
if (await this.retrySource(intent, source, !attempted, deadline)) attempted = true;
|
|
36380
36463
|
if (this.pendingSources.has(intent)) throw fsError("EBUSY", source);
|
|
36381
36464
|
} else {
|
|
36382
36465
|
const [entry] = await this.meta.under(intent);
|
|
@@ -36416,7 +36499,7 @@ var OpfsFs = class {
|
|
|
36416
36499
|
}
|
|
36417
36500
|
this.forget(from);
|
|
36418
36501
|
this.forget(to);
|
|
36419
|
-
for (const intent of intents) if (intent) await this.
|
|
36502
|
+
for (const intent of intents) if (intent) await this.retireIntent(intent);
|
|
36420
36503
|
} catch {
|
|
36421
36504
|
}
|
|
36422
36505
|
}
|
|
@@ -36452,7 +36535,7 @@ var OpfsFs = class {
|
|
|
36452
36535
|
}
|
|
36453
36536
|
if (!left) {
|
|
36454
36537
|
if ((await this.swapEntry(to))?.kind !== "directory") throw fsError("EIO", to);
|
|
36455
|
-
return this.commitPrivateCopy(from, to, root, intent, new Copies(), backup);
|
|
36538
|
+
return this.commitPrivateCopy(from, to, root, intent, new Copies(this.meta, intent), backup);
|
|
36456
36539
|
}
|
|
36457
36540
|
const staged2 = await this.swapEntry(backup);
|
|
36458
36541
|
if (staged2) {
|
|
@@ -36470,16 +36553,27 @@ var OpfsFs = class {
|
|
|
36470
36553
|
const [mark, placed] = await this.meta.get([from, to]);
|
|
36471
36554
|
if (mark?.vacated && mark.ino !== void 0 && mark.copyCommit?.intent === intent) {
|
|
36472
36555
|
const commit = mark.copyCommit;
|
|
36473
|
-
return this.releaseSource(intent, from, commit.to, mark.ino, rename.lock
|
|
36556
|
+
return this.releaseSource(intent, from, commit.to, mark.ino, rename.lock);
|
|
36557
|
+
}
|
|
36558
|
+
if (mark?.vacated && mark.ino !== void 0 && mark.ino !== root?.ino) {
|
|
36559
|
+
if (!mark.copyCommit)
|
|
36560
|
+
return this.releaseSource(
|
|
36561
|
+
intent,
|
|
36562
|
+
from,
|
|
36563
|
+
to,
|
|
36564
|
+
mark.ino,
|
|
36565
|
+
rename.lock,
|
|
36566
|
+
!root || placed?.ino !== root.ino
|
|
36567
|
+
);
|
|
36568
|
+
return this.retireIntent(intent);
|
|
36474
36569
|
}
|
|
36475
36570
|
const left = await this.real(from);
|
|
36476
|
-
|
|
36477
|
-
return this.releaseSource(intent, from, to, mark.ino, rename.lock);
|
|
36571
|
+
await this.meta.remove([manifestRoot(intent)]);
|
|
36478
36572
|
if (rename.privateCopy) {
|
|
36479
36573
|
if (left) {
|
|
36480
36574
|
const src = await this.locate(from, false);
|
|
36481
36575
|
const dir = await this.locate(parentOf11(to), true);
|
|
36482
|
-
const copies = new Copies();
|
|
36576
|
+
const copies = new Copies(this.meta, intent);
|
|
36483
36577
|
await this.duplicate(
|
|
36484
36578
|
src.handle,
|
|
36485
36579
|
dir.handle,
|
|
@@ -36488,14 +36582,14 @@ var OpfsFs = class {
|
|
|
36488
36582
|
""
|
|
36489
36583
|
);
|
|
36490
36584
|
await this.commitPrivateCopy(from, to, root ?? { ino: inodeOf(from) }, intent, copies);
|
|
36491
|
-
} else await this.
|
|
36585
|
+
} else await this.retireIntent(intent);
|
|
36492
36586
|
return;
|
|
36493
36587
|
}
|
|
36494
36588
|
await this.resumeCoordinatedCopy(intent, rename, left);
|
|
36495
36589
|
}
|
|
36496
36590
|
async resumeCoordinatedCopy(intent, rename, left) {
|
|
36497
36591
|
const { from, to, replace, root } = rename;
|
|
36498
|
-
const copies = new Copies();
|
|
36592
|
+
const copies = new Copies(this.meta, intent);
|
|
36499
36593
|
if (left && replace && await this.real(to))
|
|
36500
36594
|
await PLAIN3.rm.call(this, to, { recursive: true });
|
|
36501
36595
|
if (left) {
|
|
@@ -36510,7 +36604,7 @@ var OpfsFs = class {
|
|
|
36510
36604
|
this.forget(from);
|
|
36511
36605
|
this.forget(to);
|
|
36512
36606
|
}
|
|
36513
|
-
const mark = left ? vacatedAt(from, copies.marker(
|
|
36607
|
+
const mark = left ? vacatedAt(from, await copies.manifest?.marker(to)) : void 0;
|
|
36514
36608
|
if ((await this.meta.under(from)).some((entry) => !entry.vacated)) {
|
|
36515
36609
|
await this.meta.move(
|
|
36516
36610
|
from,
|
|
@@ -36524,8 +36618,8 @@ var OpfsFs = class {
|
|
|
36524
36618
|
mark
|
|
36525
36619
|
);
|
|
36526
36620
|
} else if (mark) await this.meta.update(from, () => mark);
|
|
36527
|
-
if (mark) await this.releaseSource(intent, from, to, mark.ino, rename.lock
|
|
36528
|
-
else await this.
|
|
36621
|
+
if (mark) await this.releaseSource(intent, from, to, mark.ino, rename.lock);
|
|
36622
|
+
else await this.retireIntent(intent);
|
|
36529
36623
|
this.remote?.emit({ paths: [], trees: [], moved: { from, to } });
|
|
36530
36624
|
}
|
|
36531
36625
|
async finishRename(entry) {
|
|
@@ -36681,6 +36775,7 @@ var OpfsFs = class {
|
|
|
36681
36775
|
const before = this.fileMoves;
|
|
36682
36776
|
try {
|
|
36683
36777
|
await this.copy(handle, dir, name2, { copies });
|
|
36778
|
+
await copies.manifest?.flush();
|
|
36684
36779
|
} catch (err) {
|
|
36685
36780
|
if (handle.kind === "directory" && this.fileMoves === before) {
|
|
36686
36781
|
await this.io(dir.removeEntry(name2, { recursive: true }));
|
|
@@ -36727,7 +36822,7 @@ var OpfsFs = class {
|
|
|
36727
36822
|
if (await this.moveChild(handle, dir, name2)) return;
|
|
36728
36823
|
return this.copyBytes(handle, dir, name2, options, rest2);
|
|
36729
36824
|
}
|
|
36730
|
-
|
|
36825
|
+
await options.copies?.manifest?.record(await copiedEntry(handle, rest2));
|
|
36731
36826
|
const target = await this.io(dir.getDirectoryHandle(name2, { create: true }));
|
|
36732
36827
|
this.others++;
|
|
36733
36828
|
for await (const child2 of handle.values()) {
|
|
@@ -36736,6 +36831,7 @@ var OpfsFs = class {
|
|
|
36736
36831
|
}
|
|
36737
36832
|
async copyBytes(handle, dir, name2, options, rest2) {
|
|
36738
36833
|
const file = await this.io(handle.getFile());
|
|
36834
|
+
await options.copies?.manifest?.record(await copiedEntry(handle, rest2, file));
|
|
36739
36835
|
const made2 = await this.io(dir.getFileHandle(name2, { create: true }));
|
|
36740
36836
|
const writable3 = await this.io(made2.createWritable());
|
|
36741
36837
|
try {
|
|
@@ -36745,7 +36841,6 @@ var OpfsFs = class {
|
|
|
36745
36841
|
await writable3.abort().catch(nothing2);
|
|
36746
36842
|
throw err;
|
|
36747
36843
|
}
|
|
36748
|
-
if (options.copies) options.copies.remaining.push(await copiedEntry(handle, rest2, file));
|
|
36749
36844
|
options.copies?.set(rest2, {
|
|
36750
36845
|
before: options.copies.get(rest2)?.before ?? file.lastModified,
|
|
36751
36846
|
made: made2
|
|
@@ -36887,7 +36982,7 @@ var OpfsFs = class {
|
|
|
36887
36982
|
const entries = await this.meta.all();
|
|
36888
36983
|
const carried = new Set(entries.filter((e) => !e.vacated).map((e) => e.ino));
|
|
36889
36984
|
const checked = entries.filter(
|
|
36890
|
-
(e) => !e.rename && !(e.vacated && carried.has(inodeOf(e.path)))
|
|
36985
|
+
(e) => !e.rename && !e.copyStamp && !(e.vacated && carried.has(inodeOf(e.path)))
|
|
36891
36986
|
);
|
|
36892
36987
|
const real2 = await this.present(
|
|
36893
36988
|
checked.flatMap((e) => e.link === void 0 ? [e.path] : [e.path, parentOf11(e.path)])
|