@ai-ecoverse/slicc-kernel 1.196.13 → 1.196.14

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.
@@ -3031,7 +3031,6 @@ var OpfsFs = class {
3031
3031
  if (!crowded && options?.alone !== true) {
3032
3032
  throw fsError("ENOTSUP", `${path}: appended by position while no other tab shares the root`);
3033
3033
  }
3034
- if (crowded) await this.remote?.peered();
3035
3034
  const at = normalizePath(path);
3036
3035
  if (this.renamesInFlight()) await this.writeWaits(at);
3037
3036
  const ended = this.writeStarted(at);
@@ -3466,7 +3465,7 @@ var OpfsFs = class {
3466
3465
  let lock;
3467
3466
  const hooks = {};
3468
3467
  const staging = swap ? `.${name2}.${crypto.randomUUID()}` : name2;
3469
- const copying = sourceStat.isDirectory && !movable(source.handle);
3468
+ const copying = swap || sourceStat.isDirectory && !movable(source.handle);
3470
3469
  const staged2 = resolvePath(parent.path, staging);
3471
3470
  const place = async () => {
3472
3471
  this.forget(destination);
@@ -3484,7 +3483,7 @@ var OpfsFs = class {
3484
3483
  });
3485
3484
  const moved2 = await this.replacingTarget(
3486
3485
  targetStat !== null,
3487
- () => this.place(source.handle, dir, staging, copies)
3486
+ () => this.place(source.handle, dir, staging, copies, copying)
3488
3487
  ).catch(async (err) => {
3489
3488
  if (first) await this.rollBack(staged2, source.path, [first, second]);
3490
3489
  throw err;
@@ -3497,7 +3496,7 @@ var OpfsFs = class {
3497
3496
  if (first) await this.meta.update(first, () => void 0);
3498
3497
  if (swap) {
3499
3498
  const hidden = await dir.getDirectoryHandle(staging);
3500
- const placed = await this.place(hidden, dir, name2, copies);
3499
+ const placed = await this.place(hidden, dir, name2, copies, copying);
3501
3500
  if (!placed) await dir.removeEntry(staging, { recursive: true });
3502
3501
  }
3503
3502
  if (second) await this.meta.update(second, () => void 0);
@@ -3506,6 +3505,7 @@ var OpfsFs = class {
3506
3505
  this.touch(Date.now(), parentOf4(source.path), parent.path);
3507
3506
  };
3508
3507
  if (!copying) return sourceStat.isDirectory ? place() : this.movingFile(source.path, place);
3508
+ if (this.remote && !this.locks) throw fsError("EBUSY", source.path);
3509
3509
  const { promise, resolve: resolve2 } = Promise.withResolvers();
3510
3510
  const entry = { from: source.path, to: destination, done: promise };
3511
3511
  this.renamingDirs.add(entry);
@@ -3768,6 +3768,7 @@ var OpfsFs = class {
3768
3768
  return this.remote !== void 0 && this.locks !== void 0 && this.shared();
3769
3769
  }
3770
3770
  async peerOp(name2, args, inner) {
3771
+ if (name2 === "append") await this.remote?.peered();
3771
3772
  const paths = (name2 === "symlink" ? args.slice(1, 2) : PAIRED.has(name2) ? args.slice(0, 2) : args.slice(0, 1)).filter((path) => typeof path === "string").map(normalizePath);
3772
3773
  const listing = LISTINGS.has(name2);
3773
3774
  const removing = REMOVALS.has(name2);
@@ -3807,7 +3808,8 @@ var OpfsFs = class {
3807
3808
  await this.copy(
3808
3809
  moved2.handle,
3809
3810
  back.handle,
3810
- baseOf(to)
3811
+ baseOf(to),
3812
+ { restoring: true }
3811
3813
  );
3812
3814
  const [dir, name2] = await this.parent(from);
3813
3815
  await this.inDir(dir, (parent) => parent.removeEntry(name2, { recursive: true }));
@@ -4002,11 +4004,12 @@ var OpfsFs = class {
4002
4004
  await this.meta.update(path + rest2, (entry) => entry && { ...entry, mtimeFor });
4003
4005
  }
4004
4006
  }
4005
- async place(handle, dir, name2, copies) {
4006
- if (await this.moved(handle, dir, name2)) return true;
4007
+ async place(handle, dir, name2, copies, admitted) {
4008
+ if (await this.moved(handle, dir, name2, admitted)) return true;
4009
+ if (!admitted) throw fsError("EBUSY", name2);
4007
4010
  const before = this.fileMoves;
4008
4011
  try {
4009
- await this.copy(handle, dir, name2, copies);
4012
+ await this.copy(handle, dir, name2, { copies });
4010
4013
  } catch (err) {
4011
4014
  if (handle.kind === "directory" && this.fileMoves === before) {
4012
4015
  await this.io(dir.removeEntry(name2, { recursive: true }));
@@ -4016,48 +4019,61 @@ var OpfsFs = class {
4016
4019
  return false;
4017
4020
  }
4018
4021
  fileMoves = 0;
4019
- async moved(handle, dir, name2) {
4022
+ async moved(handle, dir, name2, canCopyLocked) {
4020
4023
  const move = handle.move;
4021
4024
  if (!move) return false;
4022
4025
  for (let attempt = 0; ; attempt++) {
4023
4026
  this.others++;
4024
- const failed4 = await move.call(handle, dir, name2).then(
4025
- () => void 0,
4026
- (err) => ({ err })
4027
- );
4028
- if (!failed4) return true;
4029
- const error = failed4.err?.name;
4030
- if (handle.kind !== "file" || !LOCKED.has(error)) return false;
4031
- const delay2 = SYNC_BACKOFF_MS[attempt];
4032
- if (delay2 === void 0) throw fsError("EBUSY", name2);
4033
- await new Promise((resolve2) => setTimeout(resolve2, delay2));
4027
+ try {
4028
+ await move.call(handle, dir, name2);
4029
+ return true;
4030
+ } catch (err) {
4031
+ const error = err;
4032
+ if (error?.name === "NotSupportedError" || error?.code === "ENOTSUP" || error?.code === "EOPNOTSUPP")
4033
+ return false;
4034
+ if (!LOCKED.has(error?.name ?? "")) throw translate(err, name2, "write");
4035
+ if (canCopyLocked) return false;
4036
+ const delay2 = SYNC_BACKOFF_MS[attempt];
4037
+ if (handle.kind !== "file" || delay2 === void 0) throw fsError("EBUSY", name2);
4038
+ await new Promise((resolve2) => setTimeout(resolve2, delay2));
4039
+ }
4034
4040
  }
4035
4041
  }
4036
- async copy(handle, dir, name2, copies, rest2 = "") {
4037
- if (handle.kind === "file" && movable(handle)) {
4038
- this.others++;
4039
- const moved2 = await handle.move?.(dir, name2).then(
4040
- () => true,
4041
- () => false
4042
- );
4043
- if (moved2) {
4044
- this.fileMoves++;
4045
- return;
4046
- }
4042
+ async moveChild(file, dir, name2) {
4043
+ if (!file.move) return false;
4044
+ this.others++;
4045
+ try {
4046
+ await file.move(dir, name2);
4047
+ } catch {
4048
+ return false;
4047
4049
  }
4050
+ this.fileMoves++;
4051
+ return true;
4052
+ }
4053
+ async copy(handle, dir, name2, options = {}, rest2 = "") {
4048
4054
  if (handle.kind === "file") {
4055
+ if (options.restoring && await this.handleExists(dir, name2)) return;
4056
+ if (await this.moveChild(handle, dir, name2)) return;
4057
+ const file = await this.io(handle.getFile());
4049
4058
  const made2 = await this.io(dir.getFileHandle(name2, { create: true }));
4050
4059
  const writable3 = await this.io(made2.createWritable());
4051
- const file = await this.io(handle.getFile());
4052
- await writable3.write(file);
4053
- await writable3.close();
4054
- copies?.set(rest2, { before: copies.get(rest2)?.before ?? file.lastModified, made: made2 });
4060
+ try {
4061
+ await writable3.write(file);
4062
+ await writable3.close();
4063
+ } catch (err) {
4064
+ await writable3.abort().catch(nothing);
4065
+ throw err;
4066
+ }
4067
+ options.copies?.set(rest2, {
4068
+ before: options.copies.get(rest2)?.before ?? file.lastModified,
4069
+ made: made2
4070
+ });
4055
4071
  return;
4056
4072
  }
4057
4073
  const target = await this.io(dir.getDirectoryHandle(name2, { create: true }));
4058
4074
  this.others++;
4059
4075
  for await (const child2 of handle.values()) {
4060
- await this.copy(child2, target, child2.name, copies, `${rest2}/${child2.name}`);
4076
+ await this.copy(child2, target, child2.name, options, `${rest2}/${child2.name}`);
4061
4077
  }
4062
4078
  }
4063
4079
  async symlink(target, path, owner) {
@@ -9565,7 +9581,7 @@ function satisfies(version, range2) {
9565
9581
  }
9566
9582
 
9567
9583
  // src/version.ts
9568
- var KERNEL_VERSION = true ? "1.196.13" : "0.0.0-dev";
9584
+ var KERNEL_VERSION = true ? "1.196.14" : "0.0.0-dev";
9569
9585
  var OS_RELEASE = "6.0.0-slicc";
9570
9586
  function procVersion() {
9571
9587
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC