@ai-ecoverse/slicc-kernel 1.196.51 → 1.196.52

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.
@@ -4300,7 +4300,7 @@ var OpfsFs = class {
4300
4300
  if (!missing2(err)) throw err;
4301
4301
  });
4302
4302
  }
4303
- async commitPrivateCopy(from, to, root, intent, copies, emptyBackup) {
4303
+ async commitPrivateCopy(from, to, root, intent, copies, emptyBackup, lock) {
4304
4304
  const { ino, ...owner } = root;
4305
4305
  const entries = await this.meta.get([from, to]);
4306
4306
  let mark = entries[0];
@@ -4313,7 +4313,7 @@ var OpfsFs = class {
4313
4313
  mark
4314
4314
  );
4315
4315
  }
4316
- if (!emptyBackup) await this.releaseSource(intent, from, to, mark.ino);
4316
+ if (!emptyBackup) await this.releaseSource(intent, from, to, mark.ino, lock);
4317
4317
  this.movePending(from, to);
4318
4318
  await this.restamp(to, copies);
4319
4319
  this.changed(from, to);
@@ -4405,13 +4405,18 @@ var OpfsFs = class {
4405
4405
  if (signal) await this.locks.request(key, { signal }, remove);
4406
4406
  else await this.locks.request(key, remove);
4407
4407
  }
4408
- async duplicate(handle, parent, name2, copies, rest2) {
4409
- if (handle.kind === "file") return this.copyBytes(handle, parent, name2, { copies }, rest2);
4410
- await copies.manifest?.record(await copiedEntry(handle, rest2));
4408
+ async duplicate(handle, parent, name2, copies, rest2, vacantOnly = false) {
4409
+ if (handle.kind === "file")
4410
+ return this.copyBytes(handle, parent, name2, { copies, vacantOnly }, rest2);
4411
+ if (vacantOnly && await this.handleExists(parent, name2)) throw fsError("EEXIST", name2);
4411
4412
  const dir = await this.io(parent.getDirectoryHandle(name2, { create: true }));
4412
4413
  this.others++;
4414
+ await this.duplicateContents(handle, dir, copies, rest2, vacantOnly);
4415
+ }
4416
+ async duplicateContents(handle, dir, copies, rest2, vacantOnly = false) {
4417
+ await copies.manifest?.record(await copiedEntry(handle, rest2));
4413
4418
  for await (const child2 of handle.values())
4414
- await this.duplicate(child2, dir, child2.name, copies, rest2 + "/" + child2.name);
4419
+ await this.duplicate(child2, dir, child2.name, copies, rest2 + "/" + child2.name, vacantOnly);
4415
4420
  }
4416
4421
  hiddenBackups = /* @__PURE__ */ new Set();
4417
4422
  pendingSources = /* @__PURE__ */ new Map();
@@ -4553,6 +4558,49 @@ var OpfsFs = class {
4553
4558
  }
4554
4559
  await this.dropSwapIntent(intent, backup);
4555
4560
  }
4561
+ async vacantLegacyGeneration(from, to, generation) {
4562
+ const [mark, ...parents] = await (this.meta.fresh ?? this.meta.get).call(this.meta, [
4563
+ from,
4564
+ ...prefixes(parentOf4(to))
4565
+ ]);
4566
+ return mark?.vacated === true && mark.ino === generation && !mark.copyCommit && !parents.some((p) => p?.vacated || p?.link !== void 0) && (await this.meta.under(to)).length === 0;
4567
+ }
4568
+ async resumeVacantLegacy(intent, rename, generation) {
4569
+ const { from, to, root } = rename;
4570
+ const stage = /^\..+\.[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
4571
+ if (!root || rename.replace || stage.test(baseOf(from)) || stage.test(baseOf(to))) return false;
4572
+ const source = await this.swapEntry(from), parent = await this.swapEntry(parentOf4(to));
4573
+ if (source?.kind !== "directory" || parent?.kind !== "directory") return false;
4574
+ const name2 = baseOf(to);
4575
+ const target = await this.locked(to, async () => {
4576
+ if (!await this.vacantLegacyGeneration(from, to, generation) || await this.handleExists(parent, name2))
4577
+ return void 0;
4578
+ return parent.getDirectoryHandle(name2, { create: true });
4579
+ });
4580
+ if (!target) return false;
4581
+ for await (const _ of target.keys()) return false;
4582
+ const copies = new Copies(this.meta, intent);
4583
+ await this.meta.remove([manifestRoot(intent)]);
4584
+ try {
4585
+ await this.duplicateContents(source, target, copies, "", true);
4586
+ } catch (err) {
4587
+ if (err.code === "EEXIST") return false;
4588
+ throw err;
4589
+ }
4590
+ await copies.manifest?.flush();
4591
+ if (!await this.vacantLegacyGeneration(from, to, generation) || (await this.root.resolve(source))?.join("/") !== from.slice(1) || (await this.root.resolve(target))?.join("/") !== to.slice(1))
4592
+ return false;
4593
+ await this.commitPrivateCopy(
4594
+ from,
4595
+ to,
4596
+ { ...root, ino: generation },
4597
+ intent,
4598
+ copies,
4599
+ void 0,
4600
+ rename.lock
4601
+ );
4602
+ return true;
4603
+ }
4556
4604
  async resumeCopiedTree(intent, rename) {
4557
4605
  const { from, to, root } = rename;
4558
4606
  const [mark, placed] = await this.meta.get([from, to]);
@@ -4561,16 +4609,16 @@ var OpfsFs = class {
4561
4609
  return this.releaseSource(intent, from, commit.to, mark.ino, rename.lock);
4562
4610
  }
4563
4611
  if (mark?.vacated && mark.ino !== void 0 && mark.ino !== root?.ino) {
4564
- if (!mark.copyCommit)
4565
- return this.releaseSource(
4566
- intent,
4567
- from,
4568
- to,
4569
- mark.ino,
4570
- rename.lock,
4571
- !root || placed?.ino !== root.ino
4572
- );
4573
- return this.retireIntent(intent);
4612
+ if (mark.copyCommit) return this.retireIntent(intent);
4613
+ if (!placed && await this.resumeVacantLegacy(intent, rename, mark.ino)) return;
4614
+ return this.releaseSource(
4615
+ intent,
4616
+ from,
4617
+ to,
4618
+ mark.ino,
4619
+ rename.lock,
4620
+ !root || placed?.ino !== root.ino
4621
+ );
4574
4622
  }
4575
4623
  const left = await this.real(from);
4576
4624
  await this.meta.remove([manifestRoot(intent)]);
@@ -4837,6 +4885,7 @@ var OpfsFs = class {
4837
4885
  async copyBytes(handle, dir, name2, options, rest2) {
4838
4886
  const file = await this.io(handle.getFile());
4839
4887
  await options.copies?.manifest?.record(await copiedEntry(handle, rest2, file));
4888
+ if (options.vacantOnly && await this.handleExists(dir, name2)) throw fsError("EEXIST", name2);
4840
4889
  const made2 = await this.io(dir.getFileHandle(name2, { create: true }));
4841
4890
  const writable3 = await this.io(made2.createWritable());
4842
4891
  try {
@@ -10463,7 +10512,7 @@ function satisfies(version, range2) {
10463
10512
  }
10464
10513
 
10465
10514
  // src/version.ts
10466
- var KERNEL_VERSION = true ? "1.196.51" : "0.0.0-dev";
10515
+ var KERNEL_VERSION = true ? "1.196.52" : "0.0.0-dev";
10467
10516
  var OS_RELEASE = "6.0.0-slicc";
10468
10517
  function procVersion() {
10469
10518
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC