@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/node.js
CHANGED
|
@@ -7845,7 +7845,7 @@ function satisfies(version, range2) {
|
|
|
7845
7845
|
}
|
|
7846
7846
|
|
|
7847
7847
|
// src/version.ts
|
|
7848
|
-
var KERNEL_VERSION = true ? "1.196.
|
|
7848
|
+
var KERNEL_VERSION = true ? "1.196.45" : "0.0.0-dev";
|
|
7849
7849
|
var OS_RELEASE = "6.0.0-slicc";
|
|
7850
7850
|
function procVersion() {
|
|
7851
7851
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -34262,9 +34262,9 @@ async function copiedEntry(handle, path, file) {
|
|
|
34262
34262
|
function absent(err) {
|
|
34263
34263
|
return err.name === "NotFoundError";
|
|
34264
34264
|
}
|
|
34265
|
-
async function removeOne(parent, name2, rest2,
|
|
34265
|
+
async function removeOne(parent, name2, rest2, lookup4, signal) {
|
|
34266
34266
|
signal?.throwIfAborted();
|
|
34267
|
-
const entry =
|
|
34267
|
+
const entry = await lookup4(rest2);
|
|
34268
34268
|
if (!entry) return;
|
|
34269
34269
|
try {
|
|
34270
34270
|
const handle = entry.kind === "file" ? await parent.getFileHandle(name2) : await parent.getDirectoryHandle(name2);
|
|
@@ -34274,7 +34274,7 @@ async function removeOne(parent, name2, rest2, entries, signal) {
|
|
|
34274
34274
|
if (file.lastModified !== entry.mtime || file.size !== entry.size) return;
|
|
34275
34275
|
} else {
|
|
34276
34276
|
for await (const child2 of handle.keys())
|
|
34277
|
-
await removeOne(handle, child2, rest2 + "/" + child2,
|
|
34277
|
+
await removeOne(handle, child2, rest2 + "/" + child2, lookup4, signal);
|
|
34278
34278
|
}
|
|
34279
34279
|
signal?.throwIfAborted();
|
|
34280
34280
|
await parent.removeEntry(name2);
|
|
@@ -34282,10 +34282,64 @@ async function removeOne(parent, name2, rest2, entries, signal) {
|
|
|
34282
34282
|
if (!absent(err) && err.name !== "TypeMismatchError") throw err;
|
|
34283
34283
|
}
|
|
34284
34284
|
}
|
|
34285
|
-
function removeCopied(parent, name2, manifest, signal) {
|
|
34286
|
-
|
|
34285
|
+
function removeCopied(parent, name2, manifest, signal, overflow) {
|
|
34286
|
+
const entries = new Map(manifest.map((entry) => [entry.path, entry]));
|
|
34287
|
+
return removeOne(parent, name2, "", (path) => entries.get(path) ?? overflow?.(path), signal);
|
|
34287
34288
|
}
|
|
34288
34289
|
|
|
34290
|
+
// src/fs/rename-manifest.ts
|
|
34291
|
+
var INLINE_BYTES = 256 * 1024;
|
|
34292
|
+
var BATCH = 64;
|
|
34293
|
+
function manifestRoot(intent) {
|
|
34294
|
+
return "rename-manifest:" + intent;
|
|
34295
|
+
}
|
|
34296
|
+
async function storedStamp(meta, intent, path) {
|
|
34297
|
+
const [row] = await meta.get([manifestRoot(intent) + path]);
|
|
34298
|
+
return row?.copyStamp && { path, ...row.copyStamp };
|
|
34299
|
+
}
|
|
34300
|
+
var RenameManifest = class {
|
|
34301
|
+
meta;
|
|
34302
|
+
intent;
|
|
34303
|
+
entries = [];
|
|
34304
|
+
pending = [];
|
|
34305
|
+
bytes = 2;
|
|
34306
|
+
indexed = false;
|
|
34307
|
+
constructor(meta, intent) {
|
|
34308
|
+
this.meta = meta;
|
|
34309
|
+
this.intent = intent;
|
|
34310
|
+
}
|
|
34311
|
+
async record(entry) {
|
|
34312
|
+
if (!this.indexed) {
|
|
34313
|
+
this.bytes += storedSize(JSON.stringify(entry)) + 1;
|
|
34314
|
+
if (this.bytes <= INLINE_BYTES) {
|
|
34315
|
+
this.entries.push(entry);
|
|
34316
|
+
return;
|
|
34317
|
+
}
|
|
34318
|
+
this.indexed = true;
|
|
34319
|
+
}
|
|
34320
|
+
const { path: relative2, ...copyStamp } = entry;
|
|
34321
|
+
const path = manifestRoot(this.intent) + relative2;
|
|
34322
|
+
this.pending.push({ path, change: () => ({ path, copyStamp }) });
|
|
34323
|
+
if (this.pending.length === BATCH) await this.flush();
|
|
34324
|
+
}
|
|
34325
|
+
async flush() {
|
|
34326
|
+
if (!this.pending.length) return;
|
|
34327
|
+
if (this.meta.updateMany) await this.meta.updateMany(this.pending);
|
|
34328
|
+
else for (const { path, change } of this.pending) await this.meta.update(path, change);
|
|
34329
|
+
this.pending.length = 0;
|
|
34330
|
+
}
|
|
34331
|
+
async marker(to) {
|
|
34332
|
+
await this.flush();
|
|
34333
|
+
if (!this.entries.length && !this.indexed) return void 0;
|
|
34334
|
+
return {
|
|
34335
|
+
intent: this.intent,
|
|
34336
|
+
to,
|
|
34337
|
+
entries: this.entries,
|
|
34338
|
+
...this.indexed && { indexed: true }
|
|
34339
|
+
};
|
|
34340
|
+
}
|
|
34341
|
+
};
|
|
34342
|
+
|
|
34289
34343
|
// src/fs/opfs.ts
|
|
34290
34344
|
var S_IFDIR2 = 16384;
|
|
34291
34345
|
var S_IFREG3 = 32768;
|
|
@@ -34333,9 +34387,10 @@ var INTENT_POLL_MS = 5;
|
|
|
34333
34387
|
var SOURCE_RETRY_MS = 250;
|
|
34334
34388
|
var SOURCE_BACKOFF_MS = 1e3;
|
|
34335
34389
|
var Copies = class extends Map {
|
|
34336
|
-
|
|
34337
|
-
|
|
34338
|
-
|
|
34390
|
+
manifest;
|
|
34391
|
+
constructor(meta, intent) {
|
|
34392
|
+
super();
|
|
34393
|
+
if (intent) this.manifest = new RenameManifest(meta, intent);
|
|
34339
34394
|
}
|
|
34340
34395
|
};
|
|
34341
34396
|
function needsCopy(handle, swap) {
|
|
@@ -36097,12 +36152,12 @@ var OpfsFs = class {
|
|
|
36097
36152
|
return this.privateCopy(source, parent, destination, target?.handle, moving);
|
|
36098
36153
|
const place = async () => {
|
|
36099
36154
|
this.forget(destination);
|
|
36100
|
-
const
|
|
36101
|
-
const root = { ino: inodeOf(source.path), ...moving };
|
|
36155
|
+
const root = { ino: sourceStat.ino, ...moving };
|
|
36102
36156
|
const owned4 = lock ? { lock } : {};
|
|
36103
36157
|
hooks.notify?.();
|
|
36104
36158
|
const first = copying ? await this.intend({ from: source.path, to: staged2, root, ...owned4 }) : void 0;
|
|
36105
36159
|
const second = copying && swap ? await this.intend({ from: staged2, to: destination, replace: true, root, ...owned4 }) : void 0;
|
|
36160
|
+
const copies = new Copies(this.meta, first);
|
|
36106
36161
|
await hooks.started?.().catch(async (err) => {
|
|
36107
36162
|
for (const intent of [first, second]) {
|
|
36108
36163
|
if (intent) await this.meta.update(intent, () => void 0);
|
|
@@ -36118,21 +36173,21 @@ var OpfsFs = class {
|
|
|
36118
36173
|
});
|
|
36119
36174
|
if (swap) await PLAIN3.rm.call(this, destination);
|
|
36120
36175
|
if (second) await this.intend({ from: staged2, to: destination, root, ...owned4 }, second);
|
|
36121
|
-
left.copyCommit = copies.marker(
|
|
36176
|
+
left.copyCommit = await copies.manifest?.marker(destination);
|
|
36122
36177
|
await this.meta.move(source.path, destination, carry, left);
|
|
36123
36178
|
this.movePending(source.path, destination);
|
|
36124
36179
|
if (!moved2 && first)
|
|
36125
|
-
await this.releaseSource(first, source.path, destination, left.ino, lock
|
|
36126
|
-
else if (first) await this.
|
|
36127
|
-
if (swap) {
|
|
36180
|
+
await this.releaseSource(first, source.path, destination, left.ino, lock);
|
|
36181
|
+
else if (first) await this.retireIntent(first);
|
|
36182
|
+
if (swap && second) {
|
|
36128
36183
|
const hidden = await dir.getDirectoryHandle(staging);
|
|
36129
|
-
copies.
|
|
36184
|
+
copies.manifest = new RenameManifest(this.meta, second);
|
|
36130
36185
|
const placed = await this.place(hidden, dir, name2, copies, copying);
|
|
36131
|
-
if (!placed
|
|
36132
|
-
const mark = vacatedAt(staged2, copies.marker(
|
|
36186
|
+
if (!placed) {
|
|
36187
|
+
const mark = vacatedAt(staged2, await copies.manifest.marker(destination));
|
|
36133
36188
|
await this.meta.update(staged2, () => mark);
|
|
36134
|
-
await this.releaseSource(second, staged2, destination, mark.ino, lock
|
|
36135
|
-
} else
|
|
36189
|
+
await this.releaseSource(second, staged2, destination, mark.ino, lock);
|
|
36190
|
+
} else await this.retireIntent(second);
|
|
36136
36191
|
}
|
|
36137
36192
|
await this.restamp(destination, copies);
|
|
36138
36193
|
this.changed(source.path, destination);
|
|
@@ -36514,7 +36569,6 @@ var OpfsFs = class {
|
|
|
36514
36569
|
const handle = source.handle;
|
|
36515
36570
|
const dir = parent.handle;
|
|
36516
36571
|
const name2 = baseOf4(to);
|
|
36517
|
-
const copies = new Copies();
|
|
36518
36572
|
const [entry] = await this.meta.get([source.path]);
|
|
36519
36573
|
const root = { ino: occupied(entry).ino ?? inodeOf(source.path), ...owner };
|
|
36520
36574
|
if (target?.kind === "directory" && movable(target) && movable(handle)) {
|
|
@@ -36524,14 +36578,23 @@ var OpfsFs = class {
|
|
|
36524
36578
|
if (await this.swapNative(source, dir, name2, target, emptyBackup, intent2)) {
|
|
36525
36579
|
this.forget(source.path);
|
|
36526
36580
|
this.forget(to);
|
|
36527
|
-
await this.commitPrivateCopy(
|
|
36581
|
+
await this.commitPrivateCopy(
|
|
36582
|
+
source.path,
|
|
36583
|
+
to,
|
|
36584
|
+
root,
|
|
36585
|
+
intent2,
|
|
36586
|
+
new Copies(this.meta, intent2),
|
|
36587
|
+
emptyBackup
|
|
36588
|
+
);
|
|
36528
36589
|
return;
|
|
36529
36590
|
}
|
|
36530
36591
|
}
|
|
36531
36592
|
await this.beforePrivateCopy?.();
|
|
36532
36593
|
const intent = await this.intend({ from: source.path, to, root, privateCopy: true });
|
|
36594
|
+
const copies = new Copies(this.meta, intent);
|
|
36533
36595
|
try {
|
|
36534
36596
|
await this.duplicate(handle, dir, name2, copies, "");
|
|
36597
|
+
await copies.manifest?.flush();
|
|
36535
36598
|
} catch (err) {
|
|
36536
36599
|
if (!target)
|
|
36537
36600
|
await dir.removeEntry(name2, { recursive: true }).catch((e) => {
|
|
@@ -36542,7 +36605,7 @@ var OpfsFs = class {
|
|
|
36542
36605
|
await target.removeEntry(child2, { recursive: true });
|
|
36543
36606
|
}
|
|
36544
36607
|
this.forget(to);
|
|
36545
|
-
await this.
|
|
36608
|
+
await this.retireIntent(intent);
|
|
36546
36609
|
throw translate(err, to, "write");
|
|
36547
36610
|
}
|
|
36548
36611
|
await this.commitPrivateCopy(source.path, to, root, intent, copies);
|
|
@@ -36569,7 +36632,7 @@ var OpfsFs = class {
|
|
|
36569
36632
|
const entries = await this.meta.get([from, to]);
|
|
36570
36633
|
let mark = entries[0];
|
|
36571
36634
|
if (!mark?.vacated || entries[1]?.ino !== ino) {
|
|
36572
|
-
mark = vacatedAt(from, copies.marker(
|
|
36635
|
+
mark = vacatedAt(from, await copies.manifest?.marker(to));
|
|
36573
36636
|
await this.meta.move(
|
|
36574
36637
|
from,
|
|
36575
36638
|
to,
|
|
@@ -36577,8 +36640,7 @@ var OpfsFs = class {
|
|
|
36577
36640
|
mark
|
|
36578
36641
|
);
|
|
36579
36642
|
}
|
|
36580
|
-
if (!emptyBackup)
|
|
36581
|
-
await this.releaseSource(intent, from, to, mark.ino, void 0, copies.remaining);
|
|
36643
|
+
if (!emptyBackup) await this.releaseSource(intent, from, to, mark.ino);
|
|
36582
36644
|
this.movePending(from, to);
|
|
36583
36645
|
await this.restamp(to, copies);
|
|
36584
36646
|
this.changed(from, to);
|
|
@@ -36600,22 +36662,45 @@ var OpfsFs = class {
|
|
|
36600
36662
|
}
|
|
36601
36663
|
return cleanupId(handle);
|
|
36602
36664
|
}
|
|
36603
|
-
|
|
36665
|
+
retireIntent(intent) {
|
|
36666
|
+
return this.meta.remove([intent, manifestRoot(intent)]);
|
|
36667
|
+
}
|
|
36668
|
+
async releaseSource(intent, from, to, id2, lock, unverified = false) {
|
|
36604
36669
|
this.syncSourceReservation(intent, from);
|
|
36605
|
-
const physicalSource = copiedEntries?.find((entry) => entry.path === "")?.id;
|
|
36606
36670
|
await this.intend(
|
|
36607
36671
|
{
|
|
36608
36672
|
from,
|
|
36609
36673
|
to,
|
|
36610
36674
|
sourceCleanup: id2,
|
|
36611
|
-
...
|
|
36612
|
-
...
|
|
36613
|
-
...copiedEntries && { copiedEntries }
|
|
36675
|
+
...unverified && { unverifiedSource: true },
|
|
36676
|
+
...lock && { lock }
|
|
36614
36677
|
},
|
|
36615
36678
|
intent
|
|
36616
36679
|
);
|
|
36617
36680
|
await this.cleanSource(intent, from, id2);
|
|
36618
36681
|
}
|
|
36682
|
+
async removeReserved(intent, from, reservation, rename, signal) {
|
|
36683
|
+
if (rename.unverifiedSource) {
|
|
36684
|
+
await this.sourceId(from);
|
|
36685
|
+
throw fsError("EBUSY", from);
|
|
36686
|
+
}
|
|
36687
|
+
const commit = reservation.copyCommit?.intent === intent ? reservation.copyCommit : void 0;
|
|
36688
|
+
const entries = commit?.entries ?? rename.copiedEntries;
|
|
36689
|
+
const expected = entries?.find((entry) => entry.path === "")?.id ?? rename.physicalSource;
|
|
36690
|
+
if (expected === void 0 || await this.sourceId(from) === expected) {
|
|
36691
|
+
const [dir, name2] = await this.parent(from);
|
|
36692
|
+
await this.inDir(dir, (parent) => {
|
|
36693
|
+
signal?.throwIfAborted();
|
|
36694
|
+
return entries ? removeCopied(
|
|
36695
|
+
parent,
|
|
36696
|
+
name2,
|
|
36697
|
+
entries,
|
|
36698
|
+
signal,
|
|
36699
|
+
commit?.indexed ? (path) => storedStamp(this.meta, intent, path) : void 0
|
|
36700
|
+
) : parent.removeEntry(name2);
|
|
36701
|
+
});
|
|
36702
|
+
}
|
|
36703
|
+
}
|
|
36619
36704
|
async cleanSource(intent, from, id2, signal) {
|
|
36620
36705
|
const remove = async () => {
|
|
36621
36706
|
if (signal?.aborted) return;
|
|
@@ -36624,14 +36709,7 @@ var OpfsFs = class {
|
|
|
36624
36709
|
const [reservation] = await (this.meta.fresh ?? this.meta.get).call(this.meta, [from]);
|
|
36625
36710
|
if (reservation?.vacated && reservation.ino === id2) {
|
|
36626
36711
|
try {
|
|
36627
|
-
|
|
36628
|
-
if (expected === void 0 || await this.sourceId(from) === expected) {
|
|
36629
|
-
const [dir, name2] = await this.parent(from);
|
|
36630
|
-
await this.inDir(dir, (parent) => {
|
|
36631
|
-
signal?.throwIfAborted();
|
|
36632
|
-
return current.rename?.copiedEntries ? removeCopied(parent, name2, current.rename.copiedEntries, signal) : parent.removeEntry(name2);
|
|
36633
|
-
});
|
|
36634
|
-
}
|
|
36712
|
+
await this.removeReserved(intent, from, reservation, current.rename, signal);
|
|
36635
36713
|
} catch (err) {
|
|
36636
36714
|
if (!missing6(err) && err.name !== "NotFoundError") return;
|
|
36637
36715
|
}
|
|
@@ -36640,7 +36718,7 @@ var OpfsFs = class {
|
|
|
36640
36718
|
(current2) => current2?.vacated && current2.ino === reservation.ino ? vacatedAt(from) : current2
|
|
36641
36719
|
);
|
|
36642
36720
|
}
|
|
36643
|
-
await this.
|
|
36721
|
+
await this.retireIntent(intent);
|
|
36644
36722
|
}
|
|
36645
36723
|
this.syncSourceReservation(intent);
|
|
36646
36724
|
};
|
|
@@ -36652,7 +36730,7 @@ var OpfsFs = class {
|
|
|
36652
36730
|
}
|
|
36653
36731
|
async duplicate(handle, parent, name2, copies, rest2) {
|
|
36654
36732
|
if (handle.kind === "file") return this.copyBytes(handle, parent, name2, { copies }, rest2);
|
|
36655
|
-
copies.
|
|
36733
|
+
await copies.manifest?.record(await copiedEntry(handle, rest2));
|
|
36656
36734
|
const dir = await this.io(parent.getDirectoryHandle(name2, { create: true }));
|
|
36657
36735
|
this.others++;
|
|
36658
36736
|
for await (const child2 of handle.values())
|
|
@@ -36661,24 +36739,27 @@ var OpfsFs = class {
|
|
|
36661
36739
|
hiddenBackups = /* @__PURE__ */ new Set();
|
|
36662
36740
|
pendingSources = /* @__PURE__ */ new Map();
|
|
36663
36741
|
retryAfter = /* @__PURE__ */ new Map();
|
|
36664
|
-
async retrySource(intent, from) {
|
|
36742
|
+
async retrySource(intent, from, mayClean, deadline) {
|
|
36665
36743
|
const now = performance.now();
|
|
36666
|
-
|
|
36667
|
-
|
|
36668
|
-
|
|
36744
|
+
if (now >= deadline) return false;
|
|
36745
|
+
const eligible = mayClean && now >= (this.retryAfter.get(intent) ?? -Infinity);
|
|
36746
|
+
let attempted = false;
|
|
36669
36747
|
if (eligible) this.retryAfter.set(intent, Infinity);
|
|
36670
36748
|
const controller = new AbortController();
|
|
36671
36749
|
const { promise, resolve: resolve2 } = Promise.withResolvers();
|
|
36672
36750
|
const timer = setTimeout(() => {
|
|
36673
36751
|
controller.abort();
|
|
36674
36752
|
resolve2();
|
|
36675
|
-
},
|
|
36753
|
+
}, deadline - now);
|
|
36676
36754
|
const retry = async () => {
|
|
36677
36755
|
const [entry] = await this.meta.under(intent);
|
|
36678
36756
|
controller.signal.throwIfAborted();
|
|
36679
36757
|
const id2 = entry?.rename?.sourceCleanup;
|
|
36680
36758
|
if (id2 === void 0) this.syncSourceReservation(intent);
|
|
36681
|
-
else if (eligible)
|
|
36759
|
+
else if (eligible) {
|
|
36760
|
+
attempted = true;
|
|
36761
|
+
await this.cleanSource(intent, from, id2, controller.signal);
|
|
36762
|
+
}
|
|
36682
36763
|
};
|
|
36683
36764
|
const attempt = retry().catch(nothing2).finally(() => {
|
|
36684
36765
|
clearTimeout(timer);
|
|
@@ -36686,6 +36767,7 @@ var OpfsFs = class {
|
|
|
36686
36767
|
this.retryAfter.set(intent, performance.now() + SOURCE_BACKOFF_MS);
|
|
36687
36768
|
});
|
|
36688
36769
|
await Promise.race([promise, attempt]);
|
|
36770
|
+
return attempted;
|
|
36689
36771
|
}
|
|
36690
36772
|
syncSourceReservation(intent, from) {
|
|
36691
36773
|
const path = from ?? this.pendingSources.get(intent);
|
|
@@ -36698,13 +36780,14 @@ var OpfsFs = class {
|
|
|
36698
36780
|
async reservedOp(name2, args) {
|
|
36699
36781
|
const touched = name2 === "symlink" ? args.slice(1, 2) : args.slice(0, PAIRED.has(name2) ? 2 : 1);
|
|
36700
36782
|
let attempted = false;
|
|
36783
|
+
let deadline;
|
|
36701
36784
|
for (const [intent, source] of this.pendingSources) {
|
|
36702
36785
|
if (!READS.includes(name2) && touched.some((p) => {
|
|
36703
36786
|
const at = normalizePath(p);
|
|
36704
36787
|
return within11(at, source) || REMOVALS2.has(name2) && (at === "/" || within11(source, at));
|
|
36705
36788
|
})) {
|
|
36706
|
-
|
|
36707
|
-
attempted = true;
|
|
36789
|
+
deadline ??= performance.now() + SOURCE_RETRY_MS;
|
|
36790
|
+
if (await this.retrySource(intent, source, !attempted, deadline)) attempted = true;
|
|
36708
36791
|
if (this.pendingSources.has(intent)) throw fsError("EBUSY", source);
|
|
36709
36792
|
} else {
|
|
36710
36793
|
const [entry] = await this.meta.under(intent);
|
|
@@ -36744,7 +36827,7 @@ var OpfsFs = class {
|
|
|
36744
36827
|
}
|
|
36745
36828
|
this.forget(from);
|
|
36746
36829
|
this.forget(to);
|
|
36747
|
-
for (const intent of intents) if (intent) await this.
|
|
36830
|
+
for (const intent of intents) if (intent) await this.retireIntent(intent);
|
|
36748
36831
|
} catch {
|
|
36749
36832
|
}
|
|
36750
36833
|
}
|
|
@@ -36780,7 +36863,7 @@ var OpfsFs = class {
|
|
|
36780
36863
|
}
|
|
36781
36864
|
if (!left) {
|
|
36782
36865
|
if ((await this.swapEntry(to))?.kind !== "directory") throw fsError("EIO", to);
|
|
36783
|
-
return this.commitPrivateCopy(from, to, root, intent, new Copies(), backup);
|
|
36866
|
+
return this.commitPrivateCopy(from, to, root, intent, new Copies(this.meta, intent), backup);
|
|
36784
36867
|
}
|
|
36785
36868
|
const staged2 = await this.swapEntry(backup);
|
|
36786
36869
|
if (staged2) {
|
|
@@ -36798,16 +36881,27 @@ var OpfsFs = class {
|
|
|
36798
36881
|
const [mark, placed] = await this.meta.get([from, to]);
|
|
36799
36882
|
if (mark?.vacated && mark.ino !== void 0 && mark.copyCommit?.intent === intent) {
|
|
36800
36883
|
const commit = mark.copyCommit;
|
|
36801
|
-
return this.releaseSource(intent, from, commit.to, mark.ino, rename.lock
|
|
36884
|
+
return this.releaseSource(intent, from, commit.to, mark.ino, rename.lock);
|
|
36885
|
+
}
|
|
36886
|
+
if (mark?.vacated && mark.ino !== void 0 && mark.ino !== root?.ino) {
|
|
36887
|
+
if (!mark.copyCommit)
|
|
36888
|
+
return this.releaseSource(
|
|
36889
|
+
intent,
|
|
36890
|
+
from,
|
|
36891
|
+
to,
|
|
36892
|
+
mark.ino,
|
|
36893
|
+
rename.lock,
|
|
36894
|
+
!root || placed?.ino !== root.ino
|
|
36895
|
+
);
|
|
36896
|
+
return this.retireIntent(intent);
|
|
36802
36897
|
}
|
|
36803
36898
|
const left = await this.real(from);
|
|
36804
|
-
|
|
36805
|
-
return this.releaseSource(intent, from, to, mark.ino, rename.lock);
|
|
36899
|
+
await this.meta.remove([manifestRoot(intent)]);
|
|
36806
36900
|
if (rename.privateCopy) {
|
|
36807
36901
|
if (left) {
|
|
36808
36902
|
const src = await this.locate(from, false);
|
|
36809
36903
|
const dir = await this.locate(parentOf11(to), true);
|
|
36810
|
-
const copies = new Copies();
|
|
36904
|
+
const copies = new Copies(this.meta, intent);
|
|
36811
36905
|
await this.duplicate(
|
|
36812
36906
|
src.handle,
|
|
36813
36907
|
dir.handle,
|
|
@@ -36816,14 +36910,14 @@ var OpfsFs = class {
|
|
|
36816
36910
|
""
|
|
36817
36911
|
);
|
|
36818
36912
|
await this.commitPrivateCopy(from, to, root ?? { ino: inodeOf(from) }, intent, copies);
|
|
36819
|
-
} else await this.
|
|
36913
|
+
} else await this.retireIntent(intent);
|
|
36820
36914
|
return;
|
|
36821
36915
|
}
|
|
36822
36916
|
await this.resumeCoordinatedCopy(intent, rename, left);
|
|
36823
36917
|
}
|
|
36824
36918
|
async resumeCoordinatedCopy(intent, rename, left) {
|
|
36825
36919
|
const { from, to, replace, root } = rename;
|
|
36826
|
-
const copies = new Copies();
|
|
36920
|
+
const copies = new Copies(this.meta, intent);
|
|
36827
36921
|
if (left && replace && await this.real(to))
|
|
36828
36922
|
await PLAIN3.rm.call(this, to, { recursive: true });
|
|
36829
36923
|
if (left) {
|
|
@@ -36838,7 +36932,7 @@ var OpfsFs = class {
|
|
|
36838
36932
|
this.forget(from);
|
|
36839
36933
|
this.forget(to);
|
|
36840
36934
|
}
|
|
36841
|
-
const mark = left ? vacatedAt(from, copies.marker(
|
|
36935
|
+
const mark = left ? vacatedAt(from, await copies.manifest?.marker(to)) : void 0;
|
|
36842
36936
|
if ((await this.meta.under(from)).some((entry) => !entry.vacated)) {
|
|
36843
36937
|
await this.meta.move(
|
|
36844
36938
|
from,
|
|
@@ -36852,8 +36946,8 @@ var OpfsFs = class {
|
|
|
36852
36946
|
mark
|
|
36853
36947
|
);
|
|
36854
36948
|
} else if (mark) await this.meta.update(from, () => mark);
|
|
36855
|
-
if (mark) await this.releaseSource(intent, from, to, mark.ino, rename.lock
|
|
36856
|
-
else await this.
|
|
36949
|
+
if (mark) await this.releaseSource(intent, from, to, mark.ino, rename.lock);
|
|
36950
|
+
else await this.retireIntent(intent);
|
|
36857
36951
|
this.remote?.emit({ paths: [], trees: [], moved: { from, to } });
|
|
36858
36952
|
}
|
|
36859
36953
|
async finishRename(entry) {
|
|
@@ -37009,6 +37103,7 @@ var OpfsFs = class {
|
|
|
37009
37103
|
const before = this.fileMoves;
|
|
37010
37104
|
try {
|
|
37011
37105
|
await this.copy(handle, dir, name2, { copies });
|
|
37106
|
+
await copies.manifest?.flush();
|
|
37012
37107
|
} catch (err) {
|
|
37013
37108
|
if (handle.kind === "directory" && this.fileMoves === before) {
|
|
37014
37109
|
await this.io(dir.removeEntry(name2, { recursive: true }));
|
|
@@ -37055,7 +37150,7 @@ var OpfsFs = class {
|
|
|
37055
37150
|
if (await this.moveChild(handle, dir, name2)) return;
|
|
37056
37151
|
return this.copyBytes(handle, dir, name2, options, rest2);
|
|
37057
37152
|
}
|
|
37058
|
-
|
|
37153
|
+
await options.copies?.manifest?.record(await copiedEntry(handle, rest2));
|
|
37059
37154
|
const target = await this.io(dir.getDirectoryHandle(name2, { create: true }));
|
|
37060
37155
|
this.others++;
|
|
37061
37156
|
for await (const child2 of handle.values()) {
|
|
@@ -37064,6 +37159,7 @@ var OpfsFs = class {
|
|
|
37064
37159
|
}
|
|
37065
37160
|
async copyBytes(handle, dir, name2, options, rest2) {
|
|
37066
37161
|
const file = await this.io(handle.getFile());
|
|
37162
|
+
await options.copies?.manifest?.record(await copiedEntry(handle, rest2, file));
|
|
37067
37163
|
const made2 = await this.io(dir.getFileHandle(name2, { create: true }));
|
|
37068
37164
|
const writable3 = await this.io(made2.createWritable());
|
|
37069
37165
|
try {
|
|
@@ -37073,7 +37169,6 @@ var OpfsFs = class {
|
|
|
37073
37169
|
await writable3.abort().catch(nothing2);
|
|
37074
37170
|
throw err;
|
|
37075
37171
|
}
|
|
37076
|
-
if (options.copies) options.copies.remaining.push(await copiedEntry(handle, rest2, file));
|
|
37077
37172
|
options.copies?.set(rest2, {
|
|
37078
37173
|
before: options.copies.get(rest2)?.before ?? file.lastModified,
|
|
37079
37174
|
made: made2
|
|
@@ -37215,7 +37310,7 @@ var OpfsFs = class {
|
|
|
37215
37310
|
const entries = await this.meta.all();
|
|
37216
37311
|
const carried = new Set(entries.filter((e) => !e.vacated).map((e) => e.ino));
|
|
37217
37312
|
const checked = entries.filter(
|
|
37218
|
-
(e) => !e.rename && !(e.vacated && carried.has(inodeOf(e.path)))
|
|
37313
|
+
(e) => !e.rename && !e.copyStamp && !(e.vacated && carried.has(inodeOf(e.path)))
|
|
37219
37314
|
);
|
|
37220
37315
|
const real = await this.present(
|
|
37221
37316
|
checked.flatMap((e) => e.link === void 0 ? [e.path] : [e.path, parentOf11(e.path)])
|