@ai-ecoverse/slicc-kernel 1.60.1 → 1.60.2

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/dist/node.js CHANGED
@@ -6234,6 +6234,19 @@ function mkdirOptions(entry, mode = 511) {
6234
6234
  const parents = 511 & ~(entry.umask?.() ?? 18) | 192;
6235
6235
  return { recursive: true, owner: { ...owner, parents } };
6236
6236
  }
6237
+ async function mkdirExclusive(entry, path, mode) {
6238
+ const { fs } = entry;
6239
+ const { owner } = mkdirOptions(entry, mode);
6240
+ const own = owner ? { owner } : {};
6241
+ try {
6242
+ await fs.mkdir(path, own);
6243
+ } catch (err) {
6244
+ if (err?.code !== "ENOENT") throw err;
6245
+ const above = owner ? { owner: { ...owner, mode: owner.parents } } : {};
6246
+ await fs.mkdir(path.slice(0, path.lastIndexOf("/")) || "/", { recursive: true, ...above });
6247
+ await fs.mkdir(path, own);
6248
+ }
6249
+ }
6237
6250
  async function chown(entry, path, req) {
6238
6251
  const cred = entry.cred?.();
6239
6252
  if (!cred) {
@@ -6266,7 +6279,7 @@ async function run(entry, path, req) {
6266
6279
  case "readdir-stat":
6267
6280
  return json2(await readdirStat(fs, path));
6268
6281
  case "mkdir":
6269
- await fs.mkdir(path, mkdirOptions(entry, req.mode));
6282
+ await (req.exclusive ? mkdirExclusive(entry, path, req.mode) : fs.mkdir(path, mkdirOptions(entry, req.mode)));
6270
6283
  return done;
6271
6284
  case "rm":
6272
6285
  await fs.rm(path, { recursive: true });