@ai-ecoverse/slicc-kernel 1.196.32 → 1.196.33
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 +263 -85
- package/dist/cloudflare.js.map +4 -4
- package/dist/kernel-worker.js +260 -85
- 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 +260 -85
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +1 -1
- package/dist/types/fs/meta.d.ts +4 -0
- package/dist/types/fs/opfs.d.ts +11 -1
- package/dist/types/fs/rename-cleanup.d.ts +12 -0
- package/package.json +1 -1
package/dist/kernel-worker.js
CHANGED
|
@@ -1852,6 +1852,44 @@ var RemoteWatch = class {
|
|
|
1852
1852
|
}
|
|
1853
1853
|
};
|
|
1854
1854
|
|
|
1855
|
+
// src/fs/rename-cleanup.ts
|
|
1856
|
+
function cleanupId(handle) {
|
|
1857
|
+
return handle.getUniqueId?.();
|
|
1858
|
+
}
|
|
1859
|
+
async function copiedEntry(handle, path, file) {
|
|
1860
|
+
const id2 = await cleanupId(handle);
|
|
1861
|
+
return {
|
|
1862
|
+
path,
|
|
1863
|
+
kind: handle.kind,
|
|
1864
|
+
...id2 !== void 0 && { id: id2 },
|
|
1865
|
+
...file && { size: file.size, mtime: file.lastModified }
|
|
1866
|
+
};
|
|
1867
|
+
}
|
|
1868
|
+
function absent(err) {
|
|
1869
|
+
return err.name === "NotFoundError";
|
|
1870
|
+
}
|
|
1871
|
+
async function removeOne(parent, name2, rest2, entries) {
|
|
1872
|
+
const entry = entries.get(rest2);
|
|
1873
|
+
if (!entry) return;
|
|
1874
|
+
try {
|
|
1875
|
+
const handle = entry.kind === "file" ? await parent.getFileHandle(name2) : await parent.getDirectoryHandle(name2);
|
|
1876
|
+
if (entry.id !== void 0 && await cleanupId(handle) !== entry.id) return;
|
|
1877
|
+
if (handle.kind === "file") {
|
|
1878
|
+
const file = await handle.getFile();
|
|
1879
|
+
if (file.lastModified !== entry.mtime || file.size !== entry.size) return;
|
|
1880
|
+
} else {
|
|
1881
|
+
for await (const child2 of handle.keys())
|
|
1882
|
+
await removeOne(handle, child2, rest2 + "/" + child2, entries);
|
|
1883
|
+
}
|
|
1884
|
+
await parent.removeEntry(name2);
|
|
1885
|
+
} catch (err) {
|
|
1886
|
+
if (!absent(err) && err.name !== "TypeMismatchError") throw err;
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
function removeCopied(parent, name2, manifest) {
|
|
1890
|
+
return removeOne(parent, name2, "", new Map(manifest.map((entry) => [entry.path, entry])));
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1855
1893
|
// src/fs/view.ts
|
|
1856
1894
|
function view(target, overrides) {
|
|
1857
1895
|
const keys2 = new Set(Object.keys(overrides));
|
|
@@ -1913,6 +1951,9 @@ var PRIVATE_COPY = /* @__PURE__ */ Symbol("private-copy");
|
|
|
1913
1951
|
var PRIVATE_NATIVE = /* @__PURE__ */ Symbol("private-native");
|
|
1914
1952
|
var ACK_SAMPLES = 4096;
|
|
1915
1953
|
var INTENT_POLL_MS = 5;
|
|
1954
|
+
var Copies = class extends Map {
|
|
1955
|
+
remaining = [];
|
|
1956
|
+
};
|
|
1916
1957
|
function needsCopy(handle, swap) {
|
|
1917
1958
|
return swap || handle.kind === "directory" && !movable(handle);
|
|
1918
1959
|
}
|
|
@@ -2433,6 +2474,7 @@ var OpfsFs = class {
|
|
|
2433
2474
|
return view(this, { rejectLinks: true });
|
|
2434
2475
|
}
|
|
2435
2476
|
refuse(path, holding = false) {
|
|
2477
|
+
this.reserveWrite(path, holding);
|
|
2436
2478
|
if (isProtected(this.guarded, path) || holding && holdsProtected(this.guarded, path)) {
|
|
2437
2479
|
throw fsError("EROFS", path);
|
|
2438
2480
|
}
|
|
@@ -2644,6 +2686,7 @@ var OpfsFs = class {
|
|
|
2644
2686
|
return this.lookups - seen.op < lookups && performance.now() - seen.at < GLANCE_CAP_MS;
|
|
2645
2687
|
}
|
|
2646
2688
|
async handle(path) {
|
|
2689
|
+
if (this.sourceReservation(path)) throw fsError("ENOENT", path);
|
|
2647
2690
|
this.lookups++;
|
|
2648
2691
|
if (split(path).length === 0) return this.root;
|
|
2649
2692
|
const cached = this.files.get(path);
|
|
@@ -3327,6 +3370,9 @@ var OpfsFs = class {
|
|
|
3327
3370
|
const name2 = baseOf(link2.path);
|
|
3328
3371
|
if (!children3.has(name2)) children3.set(name2, link2);
|
|
3329
3372
|
}
|
|
3373
|
+
for (const source of this.pendingSources.values()) {
|
|
3374
|
+
if (parentOf4(source) === found.path) children3.delete(baseOf(source));
|
|
3375
|
+
}
|
|
3330
3376
|
for (const backup of this.hiddenBackups) {
|
|
3331
3377
|
if (parentOf4(backup) === found.path) children3.delete(baseOf(backup));
|
|
3332
3378
|
}
|
|
@@ -3506,7 +3552,7 @@ var OpfsFs = class {
|
|
|
3506
3552
|
);
|
|
3507
3553
|
}
|
|
3508
3554
|
async removalParentId(path) {
|
|
3509
|
-
const parent = await
|
|
3555
|
+
const parent = await PLAIN.lstat.call(this, parentOf4(path));
|
|
3510
3556
|
return parent.isDirectory ? `${parent.dev ?? 0}:${parent.ino}` : void 0;
|
|
3511
3557
|
}
|
|
3512
3558
|
async removePhysical(path, recursive) {
|
|
@@ -3665,7 +3711,7 @@ var OpfsFs = class {
|
|
|
3665
3711
|
return this.privateCopy(source, parent, destination, target?.handle, moving);
|
|
3666
3712
|
const place = async () => {
|
|
3667
3713
|
this.forget(destination);
|
|
3668
|
-
const copies =
|
|
3714
|
+
const copies = new Copies();
|
|
3669
3715
|
const root = { ino: inodeOf(source.path), ...moving };
|
|
3670
3716
|
const owned4 = lock ? { lock } : {};
|
|
3671
3717
|
hooks.notify?.();
|
|
@@ -3684,18 +3730,23 @@ var OpfsFs = class {
|
|
|
3684
3730
|
if (first) await this.rollBack(staged2, source.path, [first, second]);
|
|
3685
3731
|
throw err;
|
|
3686
3732
|
});
|
|
3687
|
-
if (swap) await
|
|
3733
|
+
if (swap) await PLAIN.rm.call(this, destination);
|
|
3688
3734
|
if (second) await this.intend({ from: staged2, to: destination, root, ...owned4 }, second);
|
|
3689
3735
|
await this.meta.move(source.path, destination, carry, left);
|
|
3690
3736
|
this.movePending(source.path, destination);
|
|
3691
|
-
if (!moved2
|
|
3692
|
-
|
|
3737
|
+
if (!moved2 && first)
|
|
3738
|
+
await this.releaseSource(first, source.path, destination, left.ino, lock, copies.remaining);
|
|
3739
|
+
else if (first) await this.meta.update(first, () => void 0);
|
|
3693
3740
|
if (swap) {
|
|
3694
3741
|
const hidden = await dir.getDirectoryHandle(staging);
|
|
3742
|
+
copies.remaining = [];
|
|
3695
3743
|
const placed = await this.place(hidden, dir, name2, copies, copying);
|
|
3696
|
-
if (!placed
|
|
3744
|
+
if (!placed && second) {
|
|
3745
|
+
const mark = vacatedAt(staged2);
|
|
3746
|
+
await this.meta.update(staged2, () => mark);
|
|
3747
|
+
await this.releaseSource(second, staged2, destination, mark.ino, lock, copies.remaining);
|
|
3748
|
+
} else if (second) await this.meta.update(second, () => void 0);
|
|
3697
3749
|
}
|
|
3698
|
-
if (second) await this.meta.update(second, () => void 0);
|
|
3699
3750
|
await this.restamp(destination, copies);
|
|
3700
3751
|
this.changed(source.path, destination);
|
|
3701
3752
|
this.touch(Date.now(), parentOf4(source.path), parent.path);
|
|
@@ -3914,6 +3965,10 @@ var OpfsFs = class {
|
|
|
3914
3965
|
const left = (await this.meta.under(RENAMES2)).filter((entry) => entry.rename?.lock === move.lock).sort(byIntent);
|
|
3915
3966
|
for (const entry of left) await this.finishRename(entry);
|
|
3916
3967
|
});
|
|
3968
|
+
for (const entry of await this.meta.under(RENAMES2)) {
|
|
3969
|
+
if (entry.rename?.lock === move.lock && entry.rename.sourceCleanup !== void 0)
|
|
3970
|
+
this.syncSourceReservation(entry.path, entry.rename.from);
|
|
3971
|
+
}
|
|
3917
3972
|
this.peerMoves.delete(move.lock);
|
|
3918
3973
|
for (const [from, to] of move.trees) {
|
|
3919
3974
|
this.forget(from);
|
|
@@ -3941,9 +3996,10 @@ var OpfsFs = class {
|
|
|
3941
3996
|
}
|
|
3942
3997
|
aloneCalls = 0;
|
|
3943
3998
|
aloneDrain;
|
|
3944
|
-
async alonePlain(inner, args) {
|
|
3999
|
+
async alonePlain(name2, inner, args) {
|
|
3945
4000
|
this.aloneCalls++;
|
|
3946
4001
|
try {
|
|
4002
|
+
if (this.pendingSources.size) await this.reservedOp(name2, args);
|
|
3947
4003
|
return await inner.apply(this, args);
|
|
3948
4004
|
} finally {
|
|
3949
4005
|
this.aloneCalls--;
|
|
@@ -3974,6 +4030,7 @@ var OpfsFs = class {
|
|
|
3974
4030
|
for (const at of paths) checked.push(...await this.peerSettled(at, listing, removing));
|
|
3975
4031
|
if (!checked.some((at) => this.peerAt(at, listing, removing))) break;
|
|
3976
4032
|
}
|
|
4033
|
+
if (this.pendingSources.size) await this.reservedOp(name2, args);
|
|
3977
4034
|
const busy = { paths: checked, removing, release: () => void 0 };
|
|
3978
4035
|
const done5 = () => {
|
|
3979
4036
|
this.inflight.delete(busy);
|
|
@@ -4004,6 +4061,7 @@ var OpfsFs = class {
|
|
|
4004
4061
|
let sessionOwnsAdmission = false;
|
|
4005
4062
|
let native = false;
|
|
4006
4063
|
try {
|
|
4064
|
+
if (this.pendingSources.size) await this.reservedOp(name2, args);
|
|
4007
4065
|
if (name2 === "writeSession") {
|
|
4008
4066
|
const session = await inner.apply(inside2, args);
|
|
4009
4067
|
sessionOwnsAdmission = true;
|
|
@@ -4062,7 +4120,7 @@ var OpfsFs = class {
|
|
|
4062
4120
|
const handle = source.handle;
|
|
4063
4121
|
const dir = parent.handle;
|
|
4064
4122
|
const name2 = baseOf(to);
|
|
4065
|
-
const copies =
|
|
4123
|
+
const copies = new Copies();
|
|
4066
4124
|
const [entry] = await this.meta.get([source.path]);
|
|
4067
4125
|
const root = { ino: occupied(entry).ino ?? inodeOf(source.path), ...owner };
|
|
4068
4126
|
if (target?.kind === "directory" && movable(target) && movable(handle)) {
|
|
@@ -4115,16 +4173,19 @@ var OpfsFs = class {
|
|
|
4115
4173
|
async commitPrivateCopy(from, to, root, intent, copies, emptyBackup) {
|
|
4116
4174
|
const { ino, ...owner } = root;
|
|
4117
4175
|
const entries = await this.meta.get([from, to]);
|
|
4118
|
-
|
|
4176
|
+
let mark = entries[0];
|
|
4177
|
+
if (!mark?.vacated || entries[1]?.ino !== ino) {
|
|
4178
|
+
mark = vacatedAt(from);
|
|
4119
4179
|
await this.meta.move(
|
|
4120
4180
|
from,
|
|
4121
4181
|
to,
|
|
4122
4182
|
(entry) => ({ ...occupied(entry), ...owner, ino, path: to, ctimeMs: Date.now() }),
|
|
4123
|
-
|
|
4183
|
+
mark
|
|
4124
4184
|
);
|
|
4125
4185
|
}
|
|
4186
|
+
if (!emptyBackup)
|
|
4187
|
+
await this.releaseSource(intent, from, to, mark.ino, void 0, copies.remaining);
|
|
4126
4188
|
this.movePending(from, to);
|
|
4127
|
-
if (!emptyBackup) await this.removePhysical(from, true);
|
|
4128
4189
|
await this.restamp(to, copies);
|
|
4129
4190
|
this.changed(from, to);
|
|
4130
4191
|
this.touch(Date.now(), parentOf4(from), parentOf4(to));
|
|
@@ -4132,16 +4193,102 @@ var OpfsFs = class {
|
|
|
4132
4193
|
await this.intend({ from, to, root, emptyBackup, cleanupOnly: true }, intent);
|
|
4133
4194
|
return this.cleanSwapIntent(intent, emptyBackup);
|
|
4134
4195
|
}
|
|
4135
|
-
|
|
4196
|
+
}
|
|
4197
|
+
async sourceId(path) {
|
|
4198
|
+
const [dir, name2] = await this.parent(path);
|
|
4199
|
+
const parent = await this.dir(dir);
|
|
4200
|
+
let handle;
|
|
4201
|
+
try {
|
|
4202
|
+
handle = await this.child(parent, name2, "directory");
|
|
4203
|
+
} catch (err) {
|
|
4204
|
+
if (err.name !== "TypeMismatchError") throw err;
|
|
4205
|
+
handle = await this.child(parent, name2, "file");
|
|
4206
|
+
}
|
|
4207
|
+
return cleanupId(handle);
|
|
4208
|
+
}
|
|
4209
|
+
async releaseSource(intent, from, to, id2, lock, copiedEntries) {
|
|
4210
|
+
this.syncSourceReservation(intent, from);
|
|
4211
|
+
const physicalSource = copiedEntries?.find((entry) => entry.path === "")?.id;
|
|
4212
|
+
await this.intend(
|
|
4213
|
+
{
|
|
4214
|
+
from,
|
|
4215
|
+
to,
|
|
4216
|
+
sourceCleanup: id2,
|
|
4217
|
+
...lock && { lock },
|
|
4218
|
+
...physicalSource && { physicalSource },
|
|
4219
|
+
...copiedEntries && { copiedEntries }
|
|
4220
|
+
},
|
|
4221
|
+
intent
|
|
4222
|
+
);
|
|
4223
|
+
await this.cleanSource(intent, from, id2);
|
|
4224
|
+
}
|
|
4225
|
+
async cleanSource(intent, from, id2) {
|
|
4226
|
+
const remove = async () => {
|
|
4227
|
+
const [current] = await this.meta.under(intent);
|
|
4228
|
+
if (current?.rename?.sourceCleanup === id2) {
|
|
4229
|
+
const [reservation] = await (this.meta.fresh ?? this.meta.get).call(this.meta, [from]);
|
|
4230
|
+
if (reservation?.vacated && reservation.ino === id2) {
|
|
4231
|
+
try {
|
|
4232
|
+
const expected = current.rename.physicalSource;
|
|
4233
|
+
if (expected === void 0 || await this.sourceId(from) === expected) {
|
|
4234
|
+
const [dir, name2] = await this.parent(from);
|
|
4235
|
+
await this.inDir(
|
|
4236
|
+
dir,
|
|
4237
|
+
(parent) => current.rename?.copiedEntries ? removeCopied(parent, name2, current.rename.copiedEntries) : parent.removeEntry(name2)
|
|
4238
|
+
);
|
|
4239
|
+
}
|
|
4240
|
+
} catch (err) {
|
|
4241
|
+
if (!missing2(err) && err.name !== "NotFoundError") return;
|
|
4242
|
+
}
|
|
4243
|
+
await this.meta.update(
|
|
4244
|
+
from,
|
|
4245
|
+
(current2) => current2?.vacated && current2.ino === reservation.ino ? vacatedAt(from) : current2
|
|
4246
|
+
);
|
|
4247
|
+
}
|
|
4248
|
+
await this.meta.update(intent, () => void 0);
|
|
4249
|
+
}
|
|
4250
|
+
this.syncSourceReservation(intent);
|
|
4251
|
+
};
|
|
4252
|
+
this.syncSourceReservation(intent, from);
|
|
4253
|
+
if (this.locks) await this.locks.request(this.lockPrefix + intent, remove);
|
|
4254
|
+
else await remove();
|
|
4136
4255
|
}
|
|
4137
4256
|
async duplicate(handle, parent, name2, copies, rest2) {
|
|
4138
4257
|
if (handle.kind === "file") return this.copyBytes(handle, parent, name2, { copies }, rest2);
|
|
4258
|
+
copies.remaining.push(await copiedEntry(handle, rest2));
|
|
4139
4259
|
const dir = await this.io(parent.getDirectoryHandle(name2, { create: true }));
|
|
4140
4260
|
this.others++;
|
|
4141
4261
|
for await (const child2 of handle.values())
|
|
4142
4262
|
await this.duplicate(child2, dir, child2.name, copies, rest2 + "/" + child2.name);
|
|
4143
4263
|
}
|
|
4144
4264
|
hiddenBackups = /* @__PURE__ */ new Set();
|
|
4265
|
+
pendingSources = /* @__PURE__ */ new Map();
|
|
4266
|
+
syncSourceReservation(intent, from) {
|
|
4267
|
+
const path = from ?? this.pendingSources.get(intent);
|
|
4268
|
+
if (from === void 0) this.pendingSources.delete(intent);
|
|
4269
|
+
else this.pendingSources.set(intent, from);
|
|
4270
|
+
if (path) this.forget(path);
|
|
4271
|
+
}
|
|
4272
|
+
async reservedOp(name2, args) {
|
|
4273
|
+
const touched = name2 === "symlink" ? args.slice(1, 2) : args.slice(0, PAIRED.has(name2) ? 2 : 1);
|
|
4274
|
+
for (const [intent, source] of this.pendingSources) {
|
|
4275
|
+
const [entry] = await this.meta.under(intent);
|
|
4276
|
+
if (entry?.rename?.sourceCleanup === void 0) this.syncSourceReservation(intent);
|
|
4277
|
+
else if (!READS.includes(name2) && touched.some((p) => {
|
|
4278
|
+
const at = normalizePath(p);
|
|
4279
|
+
return within4(at, source) || REMOVALS.has(name2) && (at === "/" || within4(source, at));
|
|
4280
|
+
}))
|
|
4281
|
+
throw fsError("EBUSY", source);
|
|
4282
|
+
}
|
|
4283
|
+
}
|
|
4284
|
+
sourceReservation(path, ancestor = false) {
|
|
4285
|
+
for (const source of this.pendingSources.values())
|
|
4286
|
+
if (within4(path, source) || ancestor && within4(source, path)) return source;
|
|
4287
|
+
return void 0;
|
|
4288
|
+
}
|
|
4289
|
+
reserveWrite(path, ancestor = false) {
|
|
4290
|
+
if (this.sourceReservation(path, ancestor)) throw fsError("EBUSY", path);
|
|
4291
|
+
}
|
|
4145
4292
|
renamingDirs = /* @__PURE__ */ new Set();
|
|
4146
4293
|
intents = 0;
|
|
4147
4294
|
async intend(rename, at = `${RENAMES2}/${crypto.randomUUID()}`) {
|
|
@@ -4202,7 +4349,7 @@ var OpfsFs = class {
|
|
|
4202
4349
|
}
|
|
4203
4350
|
if (!left) {
|
|
4204
4351
|
if ((await this.swapEntry(to))?.kind !== "directory") throw fsError("EIO", to);
|
|
4205
|
-
return this.commitPrivateCopy(from, to, root, intent,
|
|
4352
|
+
return this.commitPrivateCopy(from, to, root, intent, new Copies(), backup);
|
|
4206
4353
|
}
|
|
4207
4354
|
const staged2 = await this.swapEntry(backup);
|
|
4208
4355
|
if (staged2) {
|
|
@@ -4215,10 +4362,72 @@ var OpfsFs = class {
|
|
|
4215
4362
|
}
|
|
4216
4363
|
await this.dropSwapIntent(intent, backup);
|
|
4217
4364
|
}
|
|
4365
|
+
async resumeCopiedTree(intent, rename) {
|
|
4366
|
+
const { from, to, root } = rename;
|
|
4367
|
+
const left = await this.real(from);
|
|
4368
|
+
if (left && root) {
|
|
4369
|
+
const [mark, placed] = await this.meta.get([from, to]);
|
|
4370
|
+
if (mark?.vacated && mark.ino !== void 0 && placed?.ino === root.ino)
|
|
4371
|
+
return this.releaseSource(intent, from, to, mark.ino, rename.lock);
|
|
4372
|
+
}
|
|
4373
|
+
if (rename.privateCopy) {
|
|
4374
|
+
if (left) {
|
|
4375
|
+
const src = await this.locate(from, false);
|
|
4376
|
+
const dir = await this.locate(parentOf4(to), true);
|
|
4377
|
+
const copies = new Copies();
|
|
4378
|
+
await this.duplicate(
|
|
4379
|
+
src.handle,
|
|
4380
|
+
dir.handle,
|
|
4381
|
+
baseOf(to),
|
|
4382
|
+
copies,
|
|
4383
|
+
""
|
|
4384
|
+
);
|
|
4385
|
+
await this.commitPrivateCopy(from, to, root ?? { ino: inodeOf(from) }, intent, copies);
|
|
4386
|
+
} else await this.meta.update(intent, () => void 0);
|
|
4387
|
+
return;
|
|
4388
|
+
}
|
|
4389
|
+
await this.resumeCoordinatedCopy(intent, rename, left);
|
|
4390
|
+
}
|
|
4391
|
+
async resumeCoordinatedCopy(intent, rename, left) {
|
|
4392
|
+
const { from, to, replace, root } = rename;
|
|
4393
|
+
const copies = new Copies();
|
|
4394
|
+
if (left && replace && await this.real(to))
|
|
4395
|
+
await PLAIN.rm.call(this, to, { recursive: true });
|
|
4396
|
+
if (left) {
|
|
4397
|
+
const source = await this.locate(from, false);
|
|
4398
|
+
const target = await this.locate(parentOf4(to), true);
|
|
4399
|
+
await this.copy(
|
|
4400
|
+
source.handle,
|
|
4401
|
+
target.handle,
|
|
4402
|
+
baseOf(to),
|
|
4403
|
+
{ copies }
|
|
4404
|
+
);
|
|
4405
|
+
this.forget(from);
|
|
4406
|
+
this.forget(to);
|
|
4407
|
+
}
|
|
4408
|
+
const mark = left ? vacatedAt(from) : void 0;
|
|
4409
|
+
if ((await this.meta.under(from)).some((entry) => !entry.vacated)) {
|
|
4410
|
+
await this.meta.move(
|
|
4411
|
+
from,
|
|
4412
|
+
to,
|
|
4413
|
+
(moved2) => ({
|
|
4414
|
+
...occupied(moved2),
|
|
4415
|
+
...root,
|
|
4416
|
+
ino: occupied(moved2).ino ?? root?.ino ?? inodeOf(from),
|
|
4417
|
+
path: to
|
|
4418
|
+
}),
|
|
4419
|
+
mark
|
|
4420
|
+
);
|
|
4421
|
+
} else if (mark) await this.meta.update(from, () => mark);
|
|
4422
|
+
if (mark) await this.releaseSource(intent, from, to, mark.ino, rename.lock, copies.remaining);
|
|
4423
|
+
else await this.meta.update(intent, () => void 0);
|
|
4424
|
+
this.remote?.emit({ paths: [], trees: [], moved: { from, to } });
|
|
4425
|
+
}
|
|
4218
4426
|
async finishRename(entry) {
|
|
4219
4427
|
const [current] = await this.meta.under(entry.path);
|
|
4220
4428
|
if (current?.rename === void 0) return;
|
|
4221
|
-
const { from, to,
|
|
4429
|
+
const { from, to, root, emptyBackup, cleanupOnly, sourceCleanup } = current.rename;
|
|
4430
|
+
if (sourceCleanup !== void 0) return this.cleanSource(entry.path, from, sourceCleanup);
|
|
4222
4431
|
if (emptyBackup) this.hiddenBackups.add(emptyBackup);
|
|
4223
4432
|
if (emptyBackup && cleanupOnly) return this.cleanSwapIntent(entry.path, emptyBackup);
|
|
4224
4433
|
const { promise, resolve: resolve2 } = Promise.withResolvers();
|
|
@@ -4238,59 +4447,7 @@ var OpfsFs = class {
|
|
|
4238
4447
|
);
|
|
4239
4448
|
return;
|
|
4240
4449
|
}
|
|
4241
|
-
|
|
4242
|
-
if (current.rename.privateCopy) {
|
|
4243
|
-
if (left) {
|
|
4244
|
-
const src = await this.locate(from, false);
|
|
4245
|
-
const dir = await this.locate(parentOf4(to), true);
|
|
4246
|
-
const copies = /* @__PURE__ */ new Map();
|
|
4247
|
-
await this.duplicate(
|
|
4248
|
-
src.handle,
|
|
4249
|
-
dir.handle,
|
|
4250
|
-
baseOf(to),
|
|
4251
|
-
copies,
|
|
4252
|
-
""
|
|
4253
|
-
);
|
|
4254
|
-
await this.commitPrivateCopy(
|
|
4255
|
-
from,
|
|
4256
|
-
to,
|
|
4257
|
-
root ?? { ino: inodeOf(from) },
|
|
4258
|
-
entry.path,
|
|
4259
|
-
copies
|
|
4260
|
-
);
|
|
4261
|
-
} else await this.meta.update(entry.path, () => void 0);
|
|
4262
|
-
return;
|
|
4263
|
-
}
|
|
4264
|
-
if (left && replace && await this.real(to))
|
|
4265
|
-
await PLAIN.rm.call(this, to, { recursive: true });
|
|
4266
|
-
if (left) {
|
|
4267
|
-
const source = await this.locate(from, false);
|
|
4268
|
-
const target = await this.locate(parentOf4(to), true);
|
|
4269
|
-
await this.copy(
|
|
4270
|
-
source.handle,
|
|
4271
|
-
target.handle,
|
|
4272
|
-
baseOf(to)
|
|
4273
|
-
);
|
|
4274
|
-
const [dir, name2] = await this.parent(from);
|
|
4275
|
-
await this.inDir(dir, (parent) => parent.removeEntry(name2, { recursive: true }));
|
|
4276
|
-
this.forget(from);
|
|
4277
|
-
this.forget(to);
|
|
4278
|
-
}
|
|
4279
|
-
if ((await this.meta.under(from)).some((entry2) => !entry2.vacated)) {
|
|
4280
|
-
await this.meta.move(
|
|
4281
|
-
from,
|
|
4282
|
-
to,
|
|
4283
|
-
(moved2) => ({
|
|
4284
|
-
...occupied(moved2),
|
|
4285
|
-
...root,
|
|
4286
|
-
ino: occupied(moved2).ino ?? root?.ino ?? inodeOf(from),
|
|
4287
|
-
path: to
|
|
4288
|
-
}),
|
|
4289
|
-
void 0
|
|
4290
|
-
);
|
|
4291
|
-
}
|
|
4292
|
-
await this.meta.update(entry.path, () => void 0);
|
|
4293
|
-
this.remote?.emit({ paths: [], trees: [], moved: { from, to } });
|
|
4450
|
+
await this.resumeCopiedTree(entry.path, current.rename);
|
|
4294
4451
|
} finally {
|
|
4295
4452
|
this.renamingDirs.delete(barrier);
|
|
4296
4453
|
resolve2();
|
|
@@ -4465,6 +4622,7 @@ var OpfsFs = class {
|
|
|
4465
4622
|
if (await this.moveChild(handle, dir, name2)) return;
|
|
4466
4623
|
return this.copyBytes(handle, dir, name2, options, rest2);
|
|
4467
4624
|
}
|
|
4625
|
+
if (options.copies) options.copies.remaining.push(await copiedEntry(handle, rest2));
|
|
4468
4626
|
const target = await this.io(dir.getDirectoryHandle(name2, { create: true }));
|
|
4469
4627
|
this.others++;
|
|
4470
4628
|
for await (const child2 of handle.values()) {
|
|
@@ -4482,6 +4640,7 @@ var OpfsFs = class {
|
|
|
4482
4640
|
await writable3.abort().catch(nothing);
|
|
4483
4641
|
throw err;
|
|
4484
4642
|
}
|
|
4643
|
+
if (options.copies) options.copies.remaining.push(await copiedEntry(handle, rest2, file));
|
|
4485
4644
|
options.copies?.set(rest2, {
|
|
4486
4645
|
before: options.copies.get(rest2)?.before ?? file.lastModified,
|
|
4487
4646
|
made: made2
|
|
@@ -4663,6 +4822,7 @@ function byIntent(a, b) {
|
|
|
4663
4822
|
return a.rename.at - b.rename.at;
|
|
4664
4823
|
}
|
|
4665
4824
|
var PLAIN = {
|
|
4825
|
+
lstat: OpfsFs.prototype.lstat,
|
|
4666
4826
|
rm: OpfsFs.prototype.rm,
|
|
4667
4827
|
realpath: OpfsFs.prototype.realpath
|
|
4668
4828
|
};
|
|
@@ -4703,7 +4863,7 @@ var WRITES = [
|
|
|
4703
4863
|
proto.createExclusive = function(...args) {
|
|
4704
4864
|
if (this.privateRename) return this.privateOp("createExclusive", args, inner);
|
|
4705
4865
|
if (this.amongPeers()) return this.peerOp("createExclusive", args, inner);
|
|
4706
|
-
return this.alonePlain(inner, args);
|
|
4866
|
+
return this.alonePlain("createExclusive", inner, args);
|
|
4707
4867
|
};
|
|
4708
4868
|
}
|
|
4709
4869
|
for (const [names2, op] of [
|
|
@@ -4719,7 +4879,7 @@ for (const [names2, op] of [
|
|
|
4719
4879
|
if (op === "read") await this.settledRename(args[0]);
|
|
4720
4880
|
if (this.amongPeers() || name2 === "writeSession")
|
|
4721
4881
|
return await this.peerOp(name2, args, inner);
|
|
4722
|
-
return await this.alonePlain(inner, args);
|
|
4882
|
+
return await this.alonePlain(name2, inner, args);
|
|
4723
4883
|
} catch (err) {
|
|
4724
4884
|
throw translate(err, String(args[0]), op, false);
|
|
4725
4885
|
}
|
|
@@ -10034,7 +10194,7 @@ function satisfies(version, range2) {
|
|
|
10034
10194
|
}
|
|
10035
10195
|
|
|
10036
10196
|
// src/version.ts
|
|
10037
|
-
var KERNEL_VERSION = true ? "1.196.
|
|
10197
|
+
var KERNEL_VERSION = true ? "1.196.33" : "0.0.0-dev";
|
|
10038
10198
|
var OS_RELEASE = "6.0.0-slicc";
|
|
10039
10199
|
function procVersion() {
|
|
10040
10200
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -13316,14 +13476,14 @@ function withCommandDirs(fs, names2, userDir = async () => void 0, owners = fals
|
|
|
13316
13476
|
}
|
|
13317
13477
|
return target?.path;
|
|
13318
13478
|
}
|
|
13319
|
-
const
|
|
13479
|
+
const absent3 = (err) => {
|
|
13320
13480
|
if (missing4(err)) return EMPTY2;
|
|
13321
13481
|
throw err;
|
|
13322
13482
|
};
|
|
13323
13483
|
async function content(path, err) {
|
|
13324
13484
|
if (!missing4(err) || !(await linked2(path))?.isFile) throw err;
|
|
13325
13485
|
const target = await redirected2(path);
|
|
13326
|
-
return target === void 0 ? EMPTY2 : fs.readFileBuffer(target).catch(
|
|
13486
|
+
return target === void 0 ? EMPTY2 : fs.readFileBuffer(target).catch(absent3);
|
|
13327
13487
|
}
|
|
13328
13488
|
const ranged2 = rangedOps(fs);
|
|
13329
13489
|
async function stat(path, real) {
|
|
@@ -13400,7 +13560,7 @@ function withCommandDirs(fs, names2, userDir = async () => void 0, owners = fals
|
|
|
13400
13560
|
pread: (path, offset, length2, version) => ranged2.pread(path, offset, length2, version).catch(async (err) => {
|
|
13401
13561
|
const target = missing4(err) ? await redirected2(path) : void 0;
|
|
13402
13562
|
if (target === void 0) throw err;
|
|
13403
|
-
return ranged2.pread(target, offset, length2).catch(
|
|
13563
|
+
return ranged2.pread(target, offset, length2).catch(absent3);
|
|
13404
13564
|
})
|
|
13405
13565
|
} : {}
|
|
13406
13566
|
};
|
|
@@ -13489,9 +13649,9 @@ function withEtcFiles(fs, files) {
|
|
|
13489
13649
|
const text = files.get(path)?.();
|
|
13490
13650
|
return text === void 0 ? void 0 : new TextEncoder().encode(text);
|
|
13491
13651
|
};
|
|
13492
|
-
const
|
|
13652
|
+
const absent3 = (path) => fs.lstat(path).then(() => false, missing5);
|
|
13493
13653
|
const follow2 = linkFollower(fs, files);
|
|
13494
|
-
const listedAbsent = async (path) => files.has(path) && await
|
|
13654
|
+
const listedAbsent = async (path) => files.has(path) && await absent3(path) ? bytesOf3(path) : void 0;
|
|
13495
13655
|
const fallback = (path, make) => async (err) => {
|
|
13496
13656
|
const at = missing5(err) ? await follow2(path) : void 0;
|
|
13497
13657
|
const bytes = at === void 0 ? void 0 : await listedAbsent(at);
|
|
@@ -13503,10 +13663,10 @@ function withEtcFiles(fs, files) {
|
|
|
13503
13663
|
const own = {
|
|
13504
13664
|
stat: (path) => fs.stat(path).catch(fallback(path, (b, at) => statOf(at, b))),
|
|
13505
13665
|
lstat: (path) => fs.lstat(path).catch(fallback(path, (b, at) => statOf(at, b))),
|
|
13506
|
-
exists: async (path) => await fs.exists(path) || files.has(path) && await
|
|
13666
|
+
exists: async (path) => await fs.exists(path) || files.has(path) && await absent3(path),
|
|
13507
13667
|
...fs.createExclusive ? {
|
|
13508
13668
|
createExclusive: async (path, owner) => {
|
|
13509
|
-
if (files.has(path) && await
|
|
13669
|
+
if (files.has(path) && await absent3(path)) throw fsError("EEXIST", path);
|
|
13510
13670
|
return fs.createExclusive.call(
|
|
13511
13671
|
fs,
|
|
13512
13672
|
path,
|
|
@@ -14164,11 +14324,11 @@ var FsWatchers = class {
|
|
|
14164
14324
|
}
|
|
14165
14325
|
},
|
|
14166
14326
|
rm: reshaping(async (path, options) => {
|
|
14167
|
-
const
|
|
14327
|
+
const absent3 = options?.force === true && await fs.lstat(path).then(
|
|
14168
14328
|
() => false,
|
|
14169
14329
|
() => true
|
|
14170
14330
|
);
|
|
14171
|
-
if (
|
|
14331
|
+
if (absent3) return fs.rm(path, options);
|
|
14172
14332
|
const retire = await retiring?.(path);
|
|
14173
14333
|
await removing(path, options);
|
|
14174
14334
|
await retire?.();
|
|
@@ -19246,8 +19406,8 @@ var DEV_PROBES = /* @__PURE__ */ new Set([
|
|
|
19246
19406
|
]);
|
|
19247
19407
|
async function devsOf(entry, req, result) {
|
|
19248
19408
|
if (req.devs !== true || !DEV_PROBES.has(req.op)) return result;
|
|
19249
|
-
const
|
|
19250
|
-
if (!
|
|
19409
|
+
const absent3 = result.ok ? result.kind === "json" && result.json === false : result.errno === "ENOENT";
|
|
19410
|
+
if (!absent3) return result;
|
|
19251
19411
|
const dev = await devTarget(entry, req, entry.fs.resolvePath(entry.cwd, req.path));
|
|
19252
19412
|
if (dev === void 0) return result;
|
|
19253
19413
|
return result.ok ? json2({ dev }) : { ...result, dev };
|
|
@@ -36864,13 +37024,13 @@ function serveFilesystem(port, handlers, capabilities = {}, options = {}) {
|
|
|
36864
37024
|
|
|
36865
37025
|
// src/mount/medium.ts
|
|
36866
37026
|
var EMPTY_ROOT = { kind: "directory", size: 0, mtime: 0, mode: 16877 };
|
|
36867
|
-
var
|
|
37027
|
+
var absent2 = () => fsError2("ENOMEDIUM", "No medium found");
|
|
36868
37028
|
function mediumSlot(lost, onLost) {
|
|
36869
37029
|
let current;
|
|
36870
37030
|
function wrap(pick) {
|
|
36871
37031
|
return async (...args) => {
|
|
36872
37032
|
const medium = current;
|
|
36873
|
-
if (!medium) throw
|
|
37033
|
+
if (!medium) throw absent2();
|
|
36874
37034
|
try {
|
|
36875
37035
|
return await pick(medium.handlers)(...args);
|
|
36876
37036
|
} catch (err) {
|
|
@@ -36879,7 +37039,7 @@ function mediumSlot(lost, onLost) {
|
|
|
36879
37039
|
current = void 0;
|
|
36880
37040
|
onLost(medium.key);
|
|
36881
37041
|
}
|
|
36882
|
-
throw
|
|
37042
|
+
throw absent2();
|
|
36883
37043
|
}
|
|
36884
37044
|
};
|
|
36885
37045
|
}
|
|
@@ -42857,7 +43017,19 @@ var Chunks = class {
|
|
|
42857
43017
|
this.size = size;
|
|
42858
43018
|
}
|
|
42859
43019
|
};
|
|
43020
|
+
var identities = /* @__PURE__ */ new WeakMap();
|
|
43021
|
+
function entryId(handle) {
|
|
43022
|
+
let id2 = identities.get(handle);
|
|
43023
|
+
if (!id2) {
|
|
43024
|
+
id2 = crypto.randomUUID();
|
|
43025
|
+
identities.set(handle, id2);
|
|
43026
|
+
}
|
|
43027
|
+
return id2;
|
|
43028
|
+
}
|
|
42860
43029
|
var MemoryFile = class {
|
|
43030
|
+
async getUniqueId() {
|
|
43031
|
+
return entryId(this);
|
|
43032
|
+
}
|
|
42861
43033
|
kind = "file";
|
|
42862
43034
|
name;
|
|
42863
43035
|
parent;
|
|
@@ -42943,6 +43115,9 @@ var MemoryFile = class {
|
|
|
42943
43115
|
}
|
|
42944
43116
|
};
|
|
42945
43117
|
var MemoryDirectory = class _MemoryDirectory {
|
|
43118
|
+
async getUniqueId() {
|
|
43119
|
+
return entryId(this);
|
|
43120
|
+
}
|
|
42946
43121
|
kind = "directory";
|
|
42947
43122
|
name;
|
|
42948
43123
|
parent;
|