@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.
@@ -5338,7 +5338,7 @@ function satisfies(version, range2) {
5338
5338
  }
5339
5339
 
5340
5340
  // src/version.ts
5341
- var KERNEL_VERSION = true ? "1.196.51" : "0.0.0-dev";
5341
+ var KERNEL_VERSION = true ? "1.196.52" : "0.0.0-dev";
5342
5342
  var OS_RELEASE = "6.0.0-slicc";
5343
5343
  function procVersion() {
5344
5344
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -36385,7 +36385,7 @@ var OpfsFs = class {
36385
36385
  if (!missing5(err)) throw err;
36386
36386
  });
36387
36387
  }
36388
- async commitPrivateCopy(from, to, root, intent, copies, emptyBackup) {
36388
+ async commitPrivateCopy(from, to, root, intent, copies, emptyBackup, lock) {
36389
36389
  const { ino, ...owner } = root;
36390
36390
  const entries = await this.meta.get([from, to]);
36391
36391
  let mark = entries[0];
@@ -36398,7 +36398,7 @@ var OpfsFs = class {
36398
36398
  mark
36399
36399
  );
36400
36400
  }
36401
- if (!emptyBackup) await this.releaseSource(intent, from, to, mark.ino);
36401
+ if (!emptyBackup) await this.releaseSource(intent, from, to, mark.ino, lock);
36402
36402
  this.movePending(from, to);
36403
36403
  await this.restamp(to, copies);
36404
36404
  this.changed(from, to);
@@ -36490,13 +36490,18 @@ var OpfsFs = class {
36490
36490
  if (signal) await this.locks.request(key, { signal }, remove);
36491
36491
  else await this.locks.request(key, remove);
36492
36492
  }
36493
- async duplicate(handle, parent, name2, copies, rest2) {
36494
- if (handle.kind === "file") return this.copyBytes(handle, parent, name2, { copies }, rest2);
36495
- await copies.manifest?.record(await copiedEntry(handle, rest2));
36493
+ async duplicate(handle, parent, name2, copies, rest2, vacantOnly = false) {
36494
+ if (handle.kind === "file")
36495
+ return this.copyBytes(handle, parent, name2, { copies, vacantOnly }, rest2);
36496
+ if (vacantOnly && await this.handleExists(parent, name2)) throw fsError("EEXIST", name2);
36496
36497
  const dir = await this.io(parent.getDirectoryHandle(name2, { create: true }));
36497
36498
  this.others++;
36499
+ await this.duplicateContents(handle, dir, copies, rest2, vacantOnly);
36500
+ }
36501
+ async duplicateContents(handle, dir, copies, rest2, vacantOnly = false) {
36502
+ await copies.manifest?.record(await copiedEntry(handle, rest2));
36498
36503
  for await (const child2 of handle.values())
36499
- await this.duplicate(child2, dir, child2.name, copies, rest2 + "/" + child2.name);
36504
+ await this.duplicate(child2, dir, child2.name, copies, rest2 + "/" + child2.name, vacantOnly);
36500
36505
  }
36501
36506
  hiddenBackups = /* @__PURE__ */ new Set();
36502
36507
  pendingSources = /* @__PURE__ */ new Map();
@@ -36638,6 +36643,49 @@ var OpfsFs = class {
36638
36643
  }
36639
36644
  await this.dropSwapIntent(intent, backup);
36640
36645
  }
36646
+ async vacantLegacyGeneration(from, to, generation) {
36647
+ const [mark, ...parents2] = await (this.meta.fresh ?? this.meta.get).call(this.meta, [
36648
+ from,
36649
+ ...prefixes(parentOf11(to))
36650
+ ]);
36651
+ return mark?.vacated === true && mark.ino === generation && !mark.copyCommit && !parents2.some((p) => p?.vacated || p?.link !== void 0) && (await this.meta.under(to)).length === 0;
36652
+ }
36653
+ async resumeVacantLegacy(intent, rename, generation) {
36654
+ const { from, to, root } = rename;
36655
+ const stage = /^\..+\.[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
36656
+ if (!root || rename.replace || stage.test(baseOf4(from)) || stage.test(baseOf4(to))) return false;
36657
+ const source = await this.swapEntry(from), parent = await this.swapEntry(parentOf11(to));
36658
+ if (source?.kind !== "directory" || parent?.kind !== "directory") return false;
36659
+ const name2 = baseOf4(to);
36660
+ const target = await this.locked(to, async () => {
36661
+ if (!await this.vacantLegacyGeneration(from, to, generation) || await this.handleExists(parent, name2))
36662
+ return void 0;
36663
+ return parent.getDirectoryHandle(name2, { create: true });
36664
+ });
36665
+ if (!target) return false;
36666
+ for await (const _ of target.keys()) return false;
36667
+ const copies = new Copies(this.meta, intent);
36668
+ await this.meta.remove([manifestRoot(intent)]);
36669
+ try {
36670
+ await this.duplicateContents(source, target, copies, "", true);
36671
+ } catch (err) {
36672
+ if (err.code === "EEXIST") return false;
36673
+ throw err;
36674
+ }
36675
+ await copies.manifest?.flush();
36676
+ 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))
36677
+ return false;
36678
+ await this.commitPrivateCopy(
36679
+ from,
36680
+ to,
36681
+ { ...root, ino: generation },
36682
+ intent,
36683
+ copies,
36684
+ void 0,
36685
+ rename.lock
36686
+ );
36687
+ return true;
36688
+ }
36641
36689
  async resumeCopiedTree(intent, rename) {
36642
36690
  const { from, to, root } = rename;
36643
36691
  const [mark, placed] = await this.meta.get([from, to]);
@@ -36646,16 +36694,16 @@ var OpfsFs = class {
36646
36694
  return this.releaseSource(intent, from, commit.to, mark.ino, rename.lock);
36647
36695
  }
36648
36696
  if (mark?.vacated && mark.ino !== void 0 && mark.ino !== root?.ino) {
36649
- if (!mark.copyCommit)
36650
- return this.releaseSource(
36651
- intent,
36652
- from,
36653
- to,
36654
- mark.ino,
36655
- rename.lock,
36656
- !root || placed?.ino !== root.ino
36657
- );
36658
- return this.retireIntent(intent);
36697
+ if (mark.copyCommit) return this.retireIntent(intent);
36698
+ if (!placed && await this.resumeVacantLegacy(intent, rename, mark.ino)) return;
36699
+ return this.releaseSource(
36700
+ intent,
36701
+ from,
36702
+ to,
36703
+ mark.ino,
36704
+ rename.lock,
36705
+ !root || placed?.ino !== root.ino
36706
+ );
36659
36707
  }
36660
36708
  const left = await this.real(from);
36661
36709
  await this.meta.remove([manifestRoot(intent)]);
@@ -36922,6 +36970,7 @@ var OpfsFs = class {
36922
36970
  async copyBytes(handle, dir, name2, options, rest2) {
36923
36971
  const file = await this.io(handle.getFile());
36924
36972
  await options.copies?.manifest?.record(await copiedEntry(handle, rest2, file));
36973
+ if (options.vacantOnly && await this.handleExists(dir, name2)) throw fsError("EEXIST", name2);
36925
36974
  const made2 = await this.io(dir.getFileHandle(name2, { create: true }));
36926
36975
  const writable3 = await this.io(made2.createWritable());
36927
36976
  try {