@openclaw/openshell-sandbox 2026.10.5-beta.4 → 2026.10.10-beta.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/README.md +1 -1
- package/node_modules/@openclaw/fs-safe/CHANGELOG.md +148 -0
- package/node_modules/@openclaw/fs-safe/README.md +20 -4
- package/node_modules/@openclaw/fs-safe/dist/advanced.d.ts +2 -1
- package/node_modules/@openclaw/fs-safe/dist/advanced.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-merge.js +28 -3
- package/node_modules/@openclaw/fs-safe/dist/archive-parser.wasm +0 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-read.js +11 -5
- package/node_modules/@openclaw/fs-safe/dist/archive-zip-loader.js +4 -2
- package/node_modules/@openclaw/fs-safe/dist/archive.js +2 -2
- package/node_modules/@openclaw/fs-safe/dist/atomic-io.js +2 -2
- package/node_modules/@openclaw/fs-safe/dist/bounded-read.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/bounded-read.js +9 -2
- package/node_modules/@openclaw/fs-safe/dist/clone-metadata.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/clone-metadata.js +2 -1
- package/node_modules/@openclaw/fs-safe/dist/config.d.ts +6 -0
- package/node_modules/@openclaw/fs-safe/dist/config.js +5 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-file-input.d.ts +3 -1
- package/node_modules/@openclaw/fs-safe/dist/copy-file-input.js +8 -7
- package/node_modules/@openclaw/fs-safe/dist/copy-link.d.ts +26 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-link.js +170 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-metadata.d.ts +9 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-metadata.js +39 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-path-admission.js +11 -2
- package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.d.ts +2 -4
- package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.js +4 -2
- package/node_modules/@openclaw/fs-safe/dist/copy-tree-portable.js +3 -6
- package/node_modules/@openclaw/fs-safe/dist/copy.js +3 -3
- package/node_modules/@openclaw/fs-safe/dist/create.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/creation-boundary.js +7 -4
- package/node_modules/@openclaw/fs-safe/dist/darwin-acl.d.ts +12 -0
- package/node_modules/@openclaw/fs-safe/dist/darwin-acl.js +29 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-durability.d.ts +7 -4
- package/node_modules/@openclaw/fs-safe/dist/directory-guard.js +20 -5
- package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.js +27 -2
- package/node_modules/@openclaw/fs-safe/dist/directory-receipt.d.ts +7 -7
- package/node_modules/@openclaw/fs-safe/dist/directory-receipt.js +9 -4
- package/node_modules/@openclaw/fs-safe/dist/durability.d.ts +2 -1
- package/node_modules/@openclaw/fs-safe/dist/entry-publication.js +2 -2
- package/node_modules/@openclaw/fs-safe/dist/exact-identity.d.ts +17 -0
- package/node_modules/@openclaw/fs-safe/dist/exact-identity.js +29 -0
- package/node_modules/@openclaw/fs-safe/dist/file-handle-transfer.js +4 -2
- package/node_modules/@openclaw/fs-safe/dist/file-hash.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/file-hash.js +11 -9
- package/node_modules/@openclaw/fs-safe/dist/file-identity.d.ts +7 -1
- package/node_modules/@openclaw/fs-safe/dist/file-identity.js +27 -5
- package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-admission.js +1 -2
- package/node_modules/@openclaw/fs-safe/dist/file-lock-sync.js +8 -1
- package/node_modules/@openclaw/fs-safe/dist/file-lock.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-lock.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/file-write-lease.d.ts +9 -0
- package/node_modules/@openclaw/fs-safe/dist/file-write-lease.js +42 -0
- package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.js +22 -15
- package/node_modules/@openclaw/fs-safe/dist/guest-native-python.js +3 -0
- package/node_modules/@openclaw/fs-safe/dist/hardlink-fallback.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/hardlink-fallback.js +5 -0
- package/node_modules/@openclaw/fs-safe/dist/index.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/index.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/json-durable-queue-ownership.js +16 -3
- package/node_modules/@openclaw/fs-safe/dist/local-file-descriptor.js +24 -13
- package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts +85 -18
- package/node_modules/@openclaw/fs-safe/dist/native-config.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/native-config.js +11 -0
- package/node_modules/@openclaw/fs-safe/dist/native-directory-observation.js +6 -4
- package/node_modules/@openclaw/fs-safe/dist/native-fallback-warning.d.ts +2 -1
- package/node_modules/@openclaw/fs-safe/dist/native-fallback-warning.js +26 -2
- package/node_modules/@openclaw/fs-safe/dist/native-guidance.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/native-guidance.js +21 -0
- package/node_modules/@openclaw/fs-safe/dist/native-move-fallback.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/native-move-fallback.js +2 -0
- package/node_modules/@openclaw/fs-safe/dist/native-operations.js +8 -6
- package/node_modules/@openclaw/fs-safe/dist/native-parent-admission.d.ts +44 -4
- package/node_modules/@openclaw/fs-safe/dist/native-parent-admission.js +85 -15
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.d.ts +3 -3
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.js +33 -6
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.d.ts +4 -1
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.js +22 -3
- package/node_modules/@openclaw/fs-safe/dist/native-policy-directory-observation.js +4 -3
- package/node_modules/@openclaw/fs-safe/dist/native-policy-parent.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/native-policy-parent.js +3 -0
- package/node_modules/@openclaw/fs-safe/dist/native-staged-file-metadata.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/native-staged-file-metadata.js +16 -0
- package/node_modules/@openclaw/fs-safe/dist/native-staged-file.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/native-staged-file.js +15 -5
- package/node_modules/@openclaw/fs-safe/dist/native-stat-identity.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/native-stat-identity.js +7 -0
- package/node_modules/@openclaw/fs-safe/dist/native-status.d.ts +17 -0
- package/node_modules/@openclaw/fs-safe/dist/native-status.js +30 -0
- package/node_modules/@openclaw/fs-safe/dist/native.d.ts +31 -4
- package/node_modules/@openclaw/fs-safe/dist/native.js +107 -9
- package/node_modules/@openclaw/fs-safe/dist/opened-realpath.js +9 -1
- package/node_modules/@openclaw/fs-safe/dist/overwrite-file-handle.js +4 -1
- package/node_modules/@openclaw/fs-safe/dist/owner-dacl-batch.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/owner-dacl.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/permission-exec.js +9 -1
- package/node_modules/@openclaw/fs-safe/dist/permissions-public.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions-public.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/permissions-windows.js +83 -47
- package/node_modules/@openclaw/fs-safe/dist/pinned-open.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-open.js +8 -3
- package/node_modules/@openclaw/fs-safe/dist/pinned-write-input.js +13 -0
- package/node_modules/@openclaw/fs-safe/dist/pinned-write-staged.js +10 -8
- package/node_modules/@openclaw/fs-safe/dist/pinned-write-types.d.ts +2 -1
- package/node_modules/@openclaw/fs-safe/dist/pinned-write.js +7 -5
- package/node_modules/@openclaw/fs-safe/dist/pipe.d.ts +9 -0
- package/node_modules/@openclaw/fs-safe/dist/pipe.js +26 -0
- package/node_modules/@openclaw/fs-safe/dist/private-directory.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/private-producer-handoff.js +2 -5
- package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.d.ts +3 -2
- package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.js +38 -10
- package/node_modules/@openclaw/fs-safe/dist/publish-copy-stage.js +92 -10
- package/node_modules/@openclaw/fs-safe/dist/publish-file-failure.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/publish-file-failure.js +3 -0
- package/node_modules/@openclaw/fs-safe/dist/publish-file.d.ts +5 -3
- package/node_modules/@openclaw/fs-safe/dist/publish-file.js +26 -20
- package/node_modules/@openclaw/fs-safe/dist/read-opened-file.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/read-opened-file.js +3 -4
- package/node_modules/@openclaw/fs-safe/dist/realpath.js +32 -0
- package/node_modules/@openclaw/fs-safe/dist/regular-file.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/regular-file.js +11 -15
- package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.js +3 -2
- package/node_modules/@openclaw/fs-safe/dist/root-copy.d.ts +18 -0
- package/node_modules/@openclaw/fs-safe/dist/root-copy.js +128 -0
- package/node_modules/@openclaw/fs-safe/dist/root-create-native.d.ts +8 -13
- package/node_modules/@openclaw/fs-safe/dist/root-create-native.js +252 -27
- package/node_modules/@openclaw/fs-safe/dist/root-directory-creation.js +5 -1
- package/node_modules/@openclaw/fs-safe/dist/root-directory-list-types.d.ts +11 -8
- package/node_modules/@openclaw/fs-safe/dist/root-directory-list.js +35 -13
- package/node_modules/@openclaw/fs-safe/dist/root-file-open-batch-sync.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/root-file-open-batch-sync.js +108 -0
- package/node_modules/@openclaw/fs-safe/dist/root-file.d.ts +7 -0
- package/node_modules/@openclaw/fs-safe/dist/root-file.js +15 -0
- package/node_modules/@openclaw/fs-safe/dist/root-impl.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/root-impl.js +154 -175
- package/node_modules/@openclaw/fs-safe/dist/root-mkdir-native.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/root-mkdir-native.js +239 -0
- package/node_modules/@openclaw/fs-safe/dist/root-move-noreplace.js +37 -15
- package/node_modules/@openclaw/fs-safe/dist/root-native-creation-path.d.ts +32 -0
- package/node_modules/@openclaw/fs-safe/dist/root-native-creation-path.js +56 -0
- package/node_modules/@openclaw/fs-safe/dist/root-options.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/root-public-types.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/root-remove-native.js +95 -16
- package/node_modules/@openclaw/fs-safe/dist/root-remove.js +6 -4
- package/node_modules/@openclaw/fs-safe/dist/root-walk.js +23 -19
- package/node_modules/@openclaw/fs-safe/dist/root-write-admission.js +8 -6
- package/node_modules/@openclaw/fs-safe/dist/root-write-publication.js +5 -1
- package/node_modules/@openclaw/fs-safe/dist/secure-file-windows.js +3 -1
- package/node_modules/@openclaw/fs-safe/dist/secure-file.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/secure-file.js +10 -4
- package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-reclaim.js +2 -2
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-retained.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-target.js +8 -1
- package/node_modules/@openclaw/fs-safe/dist/staged-directory.d.ts +13 -0
- package/node_modules/@openclaw/fs-safe/dist/staged-directory.js +29 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-child-admission.js +5 -3
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-descriptor.d.ts +8 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-descriptor.js +13 -2
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-owner.js +71 -3
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-ownership.d.ts +2 -1
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-ownership.js +22 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-types.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/test-hooks.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/test-hooks.js +1 -0
- package/node_modules/@openclaw/fs-safe/dist/trash.js +2 -2
- package/node_modules/@openclaw/fs-safe/dist/types.d.ts +4 -0
- package/node_modules/@openclaw/fs-safe/dist/watch-native.js +2 -2
- package/node_modules/@openclaw/fs-safe/dist/windows-appcontainer.d.ts +5 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-appcontainer.js +39 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-owner.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-owner.js +25 -36
- package/node_modules/@openclaw/fs-safe/dist/windows-security-command.js +24 -5
- package/node_modules/@openclaw/fs-safe/dist/windows-security-facts.d.ts +2 -1
- package/node_modules/@openclaw/fs-safe/dist/windows-security-facts.js +4 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.exe +0 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.js +7 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-test-hooks.d.ts +16 -0
- package/node_modules/@openclaw/fs-safe/dist/windows-test-hooks.js +51 -0
- package/node_modules/@openclaw/fs-safe/dist/write-file-handle.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/write-file-handle.js +12 -10
- package/node_modules/@openclaw/fs-safe/docs/advanced.md +2 -1
- package/node_modules/@openclaw/fs-safe/docs/archive.md +16 -0
- package/node_modules/@openclaw/fs-safe/docs/config.md +71 -1
- package/node_modules/@openclaw/fs-safe/docs/contributing.md +45 -5
- package/node_modules/@openclaw/fs-safe/docs/copy.md +45 -5
- package/node_modules/@openclaw/fs-safe/docs/durability.md +34 -7
- package/node_modules/@openclaw/fs-safe/docs/errors.md +8 -0
- package/node_modules/@openclaw/fs-safe/docs/guest.md +2 -0
- package/node_modules/@openclaw/fs-safe/docs/install.md +47 -27
- package/node_modules/@openclaw/fs-safe/docs/migrating-to-0.5.md +6 -6
- package/node_modules/@openclaw/fs-safe/docs/migrating-to-0.6.md +1 -1
- package/node_modules/@openclaw/fs-safe/docs/native-helper.md +79 -6
- package/node_modules/@openclaw/fs-safe/docs/native.md +279 -8
- package/node_modules/@openclaw/fs-safe/docs/permissions.md +64 -15
- package/node_modules/@openclaw/fs-safe/docs/pipe.md +81 -0
- package/node_modules/@openclaw/fs-safe/docs/platform-capabilities.md +63 -0
- package/node_modules/@openclaw/fs-safe/docs/public-api.md +10 -0
- package/node_modules/@openclaw/fs-safe/docs/queue-link-free-design.md +237 -0
- package/node_modules/@openclaw/fs-safe/docs/quickstart.md +23 -3
- package/node_modules/@openclaw/fs-safe/docs/reading.md +56 -2
- package/node_modules/@openclaw/fs-safe/docs/regular-file.md +2 -0
- package/node_modules/@openclaw/fs-safe/docs/secret-file.md +5 -5
- package/node_modules/@openclaw/fs-safe/docs/secure-file.md +1 -1
- package/node_modules/@openclaw/fs-safe/docs/security-model.md +35 -0
- package/node_modules/@openclaw/fs-safe/docs/sidecar-lock.md +31 -13
- package/node_modules/@openclaw/fs-safe/docs/staged-file.md +18 -0
- package/node_modules/@openclaw/fs-safe/docs/store.md +15 -0
- package/node_modules/@openclaw/fs-safe/docs/temp.md +39 -0
- package/node_modules/@openclaw/fs-safe/docs/testing.md +13 -0
- package/node_modules/@openclaw/fs-safe/docs/types.md +51 -81
- package/node_modules/@openclaw/fs-safe/docs/walk.md +4 -1
- package/node_modules/@openclaw/fs-safe/docs/watch.md +3 -2
- package/node_modules/@openclaw/fs-safe/docs/writing.md +121 -14
- package/node_modules/@openclaw/fs-safe/package.json +21 -12
- package/node_modules/@openclaw/fs-safe-darwin-arm64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-darwin-arm64/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-darwin-x64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-darwin-x64/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-freebsd-arm64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-freebsd-arm64/package.json +29 -0
- package/node_modules/@openclaw/fs-safe-freebsd-x64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-freebsd-x64/package.json +29 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-linux-arm64-musl/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-musl/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-linux-x64-gnu/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-x64-gnu/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-linux-x64-musl/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-x64-musl/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/package.json +29 -0
- package/node_modules/@openclaw/fs-safe-win32-x64-msvc/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-win32-x64-msvc/package.json +1 -1
- package/package.json +5 -5
- package/node_modules/@openclaw/fs-safe/dist/windows-security-bridge.cs +0 -336
- package/node_modules/@openclaw/fs-safe/dist/windows-security-bridge.ps1 +0 -90
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ExactFileIdentity } from "./exact-identity.js";
|
|
1
2
|
import type { Stats } from "node:fs";
|
|
2
3
|
import fsSync from "node:fs";
|
|
3
4
|
export type RegularFileStatResult = {
|
|
@@ -5,6 +6,7 @@ export type RegularFileStatResult = {
|
|
|
5
6
|
} | {
|
|
6
7
|
missing: false;
|
|
7
8
|
stat: Stats;
|
|
9
|
+
exactIdentity: ExactFileIdentity;
|
|
8
10
|
};
|
|
9
11
|
type RegularFileAppendFlagConstants = Pick<typeof fsSync.constants, "O_APPEND" | "O_CREAT" | "O_WRONLY"> & Partial<Pick<typeof fsSync.constants, "O_NOFOLLOW" | "O_NONBLOCK">>;
|
|
10
12
|
export type AppendRegularFileOptions = {
|
|
@@ -24,6 +26,7 @@ export declare function readRegularFile(params: {
|
|
|
24
26
|
}): Promise<{
|
|
25
27
|
buffer: Buffer;
|
|
26
28
|
stat: Stats;
|
|
29
|
+
exactIdentity: ExactFileIdentity;
|
|
27
30
|
}>;
|
|
28
31
|
export declare function readRegularFileSync(params: {
|
|
29
32
|
filePath: string;
|
|
@@ -31,6 +34,7 @@ export declare function readRegularFileSync(params: {
|
|
|
31
34
|
}): {
|
|
32
35
|
buffer: Buffer;
|
|
33
36
|
stat: Stats;
|
|
37
|
+
exactIdentity: ExactFileIdentity;
|
|
34
38
|
};
|
|
35
39
|
export declare function appendRegularFile(options: AppendRegularFileOptions): Promise<void>;
|
|
36
40
|
export declare function appendRegularFileSync(options: AppendRegularFileOptions): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { exactFileIdentity, numberStats } from "./exact-identity.js";
|
|
1
2
|
import fsSync from "node:fs";
|
|
2
3
|
import fs from "node:fs/promises";
|
|
3
4
|
import path from "node:path";
|
|
@@ -36,7 +37,7 @@ export function statRegularFileSync(filePath) {
|
|
|
36
37
|
assertNoWindowsPathAlias(filePath, "filesystem", "file path uses a Windows filesystem namespace alias");
|
|
37
38
|
let stat;
|
|
38
39
|
try {
|
|
39
|
-
stat = fsSync.lstatSync(filePath);
|
|
40
|
+
stat = fsSync.lstatSync(filePath, { bigint: true });
|
|
40
41
|
}
|
|
41
42
|
catch (err) {
|
|
42
43
|
if (isNotFoundPathError(err)) {
|
|
@@ -47,7 +48,7 @@ export function statRegularFileSync(filePath) {
|
|
|
47
48
|
if (stat.isSymbolicLink() || !stat.isFile()) {
|
|
48
49
|
throw new Error("path must be a regular file");
|
|
49
50
|
}
|
|
50
|
-
return { missing: false, stat };
|
|
51
|
+
return { missing: false, stat: numberStats(stat), exactIdentity: exactFileIdentity(stat) };
|
|
51
52
|
}
|
|
52
53
|
export async function readRegularFile(params) {
|
|
53
54
|
const { filePath, maxBytes, before } = prepareRegularRead(params);
|
|
@@ -62,15 +63,11 @@ export async function readRegularFile(params) {
|
|
|
62
63
|
throw err;
|
|
63
64
|
}
|
|
64
65
|
try {
|
|
65
|
-
const stat = inspectOpenedRegularRead(handle.fd, filePath, before, maxBytes);
|
|
66
|
-
//
|
|
67
|
-
// the oversized content before the post-read check could reject it.
|
|
66
|
+
const { stat, exactIdentity } = inspectOpenedRegularRead(handle.fd, filePath, before, maxBytes);
|
|
67
|
+
// readFile() can stop at a short nonblocking read before EOF (for example, 9p).
|
|
68
68
|
let buffer;
|
|
69
69
|
try {
|
|
70
|
-
buffer =
|
|
71
|
-
maxBytes === undefined
|
|
72
|
-
? await handle.readFile()
|
|
73
|
-
: await readFileHandleBounded(handle, maxBytes);
|
|
70
|
+
buffer = await readFileHandleBounded(handle, maxBytes ?? Infinity);
|
|
74
71
|
}
|
|
75
72
|
catch (error) {
|
|
76
73
|
if (maxBytes !== undefined) {
|
|
@@ -78,7 +75,7 @@ export async function readRegularFile(params) {
|
|
|
78
75
|
}
|
|
79
76
|
throw error;
|
|
80
77
|
}
|
|
81
|
-
return { buffer, stat };
|
|
78
|
+
return { buffer, stat, exactIdentity };
|
|
82
79
|
}
|
|
83
80
|
finally {
|
|
84
81
|
await handle.close();
|
|
@@ -117,7 +114,6 @@ function prepareRegularRead(params) {
|
|
|
117
114
|
return { filePath, maxBytes, before };
|
|
118
115
|
}
|
|
119
116
|
function inspectOpenedRegularRead(fd, filePath, preOpenStat, maxBytes) {
|
|
120
|
-
const stat = fsSync.fstatSync(fd);
|
|
121
117
|
const identity = inspectFileIdentitySync(() => {
|
|
122
118
|
const exact = fsSync.fstatSync(fd, { bigint: true });
|
|
123
119
|
assertRegularReadStat(exact, filePath);
|
|
@@ -136,10 +132,10 @@ function inspectOpenedRegularRead(fd, filePath, preOpenStat, maxBytes) {
|
|
|
136
132
|
}
|
|
137
133
|
throw error;
|
|
138
134
|
}
|
|
139
|
-
if (maxBytes !== undefined &&
|
|
135
|
+
if (maxBytes !== undefined && identity.size > maxBytes) {
|
|
140
136
|
throw regularFileTooLargeError(filePath, maxBytes);
|
|
141
137
|
}
|
|
142
|
-
return stat;
|
|
138
|
+
return { stat: numberStats(identity), exactIdentity: exactFileIdentity(identity) };
|
|
143
139
|
}
|
|
144
140
|
export function readRegularFileSync(params) {
|
|
145
141
|
const { filePath, maxBytes, before } = prepareRegularRead(params);
|
|
@@ -154,7 +150,7 @@ export function readRegularFileSync(params) {
|
|
|
154
150
|
throw error;
|
|
155
151
|
}
|
|
156
152
|
try {
|
|
157
|
-
const stat = inspectOpenedRegularRead(fd, filePath, before, maxBytes);
|
|
153
|
+
const { stat, exactIdentity } = inspectOpenedRegularRead(fd, filePath, before, maxBytes);
|
|
158
154
|
// Keep capped reads incremental so raced growth cannot allocate unbounded content.
|
|
159
155
|
let buffer;
|
|
160
156
|
try {
|
|
@@ -168,7 +164,7 @@ export function readRegularFileSync(params) {
|
|
|
168
164
|
}
|
|
169
165
|
throw error;
|
|
170
166
|
}
|
|
171
|
-
return { buffer, stat };
|
|
167
|
+
return { buffer, stat, exactIdentity };
|
|
172
168
|
}
|
|
173
169
|
finally {
|
|
174
170
|
fsSync.closeSync(fd);
|
|
@@ -139,10 +139,11 @@ export function* writeTempFile(io, params) {
|
|
|
139
139
|
const writing = file.writeFile(params.content, true);
|
|
140
140
|
if (io.asynchronous)
|
|
141
141
|
yield writing;
|
|
142
|
-
if (io.asyncFs === fs
|
|
142
|
+
if ((io.asyncFs === fs || (process.platform === "win32" && io.syncFs === syncFs)) && !params.sync) {
|
|
143
143
|
// Matching non-durable writes have no I/O left after this identity fence.
|
|
144
144
|
const current = inspectAtomicIdentity(io, () => file.statExact(), identity, true);
|
|
145
|
-
|
|
145
|
+
const modeMask = process.platform === "win32" ? 0o200 : 0o7777;
|
|
146
|
+
if (Number(current.mode & BigInt(modeMask)) === (params.mode & modeMask))
|
|
146
147
|
return { file, identity };
|
|
147
148
|
}
|
|
148
149
|
const chmod = file.chmod(params.mode);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type BigIntStats } from "node:fs";
|
|
2
|
+
import type { OpenResult } from "./root-impl.js";
|
|
3
|
+
import type { RootContext } from "./root-context.js";
|
|
4
|
+
import type { RootCopyOptions, RootCopySource, HardlinkPolicy } from "./root-options.js";
|
|
5
|
+
import { onCopyPublication, onCopySourceAdmission, type CopyPublicationOptions } from "./copy-publication.js";
|
|
6
|
+
type RootCopyParams = RootCopyOptions & {
|
|
7
|
+
source: RootCopySource;
|
|
8
|
+
relativePath: string;
|
|
9
|
+
verifyPublished?: CopyPublicationOptions[typeof onCopyPublication];
|
|
10
|
+
admitSource?: CopyPublicationOptions[typeof onCopySourceAdmission];
|
|
11
|
+
};
|
|
12
|
+
export declare function copyFileInRoot(root: RootContext, params: RootCopyParams, openVerifiedLocalFile: (path: string, options: {
|
|
13
|
+
hardlinks?: HardlinkPolicy;
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
opened: OpenResult;
|
|
16
|
+
identity: BigIntStats;
|
|
17
|
+
}>): Promise<void>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import fsSync, {} from "node:fs";
|
|
2
|
+
import { assertCopySourceCurrent, resolveFileCopyCloneMode } from "./copy-file-input.js";
|
|
3
|
+
import { resolveCopyCloneMode } from "./copy-policy.js";
|
|
4
|
+
import { captureCopyMetadata } from "./copy-metadata.js";
|
|
5
|
+
import { admitCopyLink, assertCopyLinkAvailable } from "./copy-link.js";
|
|
6
|
+
import { assertAbsolutePathInput } from "./absolute-path.js";
|
|
7
|
+
import { assertNoNulPathInput } from "./path.js";
|
|
8
|
+
import { assertNoWindowsPathAlias } from "./windows-path-alias.js";
|
|
9
|
+
import { inspectFileIdentitySync } from "./strict-file-identity.js";
|
|
10
|
+
import { MutationAuthorityError } from "./mutation-authority.js";
|
|
11
|
+
import { serializePathWrite } from "./write-queue.js";
|
|
12
|
+
import { rootWriteQueueKey } from "./root-create-native.js";
|
|
13
|
+
import { resolvePinnedWriteTargetInRoot } from "./root-write-admission.js";
|
|
14
|
+
import { createCopyPublicationObserver, onCopyPublication, onCopySourceAdmission } from "./copy-publication.js";
|
|
15
|
+
import { isAlreadyExistsError, normalizePinnedWriteError } from "./root-errors.js";
|
|
16
|
+
import { runPinnedWriteHelper } from "./pinned-write.js";
|
|
17
|
+
import { FsSafeError } from "./errors.js";
|
|
18
|
+
export async function copyFileInRoot(root, params, openVerifiedLocalFile) {
|
|
19
|
+
params.signal?.throwIfAborted();
|
|
20
|
+
resolveCopyCloneMode(params.clone, "never");
|
|
21
|
+
if (params.sourceSymlinks !== undefined && params.sourceSymlinks !== "reject" && params.sourceSymlinks !== "copy-link") {
|
|
22
|
+
throw new FsSafeError("invalid-path", "sourceSymlinks must be reject or copy-link");
|
|
23
|
+
}
|
|
24
|
+
if (params.sourceSymlinks === "copy-link") {
|
|
25
|
+
if (typeof params.source !== "string") {
|
|
26
|
+
throw new FsSafeError("invalid-path", "sourceSymlinks: copy-link requires an absolute-path string source; open/stat capabilities cannot observe links without following them");
|
|
27
|
+
}
|
|
28
|
+
const link = await admitCopyLink(assertAbsolutePathInput(params.source), params.preserveMetadata === true, params.signal)
|
|
29
|
+
.catch(error => { throw normalizePinnedWriteError(error); });
|
|
30
|
+
if (link) {
|
|
31
|
+
if (params.overwrite === true)
|
|
32
|
+
throw new FsSafeError("invalid-path", "copy-link cannot overwrite an existing destination; omit overwrite or use false");
|
|
33
|
+
assertCopyLinkAvailable();
|
|
34
|
+
const mode = params.mode ?? (params.preserveSourceMode ? Number(link.identity.mode & 4095n) : undefined);
|
|
35
|
+
await copyInputInRoot(root, { ...params, overwrite: false }, link, mode);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const clone = resolveFileCopyCloneMode(params.clone);
|
|
40
|
+
let source;
|
|
41
|
+
let sourceIdentity;
|
|
42
|
+
if (typeof params.source === "string") {
|
|
43
|
+
assertNoNulPathInput(params.source, "source path contains a NUL byte");
|
|
44
|
+
assertNoWindowsPathAlias(params.source, "filesystem", "source path uses a Windows filesystem namespace alias");
|
|
45
|
+
({ opened: source, identity: sourceIdentity } = await openVerifiedLocalFile(params.source, {
|
|
46
|
+
hardlinks: params.sourceHardlinks,
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
source = await params.source.root.open(params.source.relativePath, params.sourceHardlinks === undefined ? undefined : { hardlinks: params.sourceHardlinks });
|
|
51
|
+
try {
|
|
52
|
+
sourceIdentity = inspectFileIdentitySync(() => fsSync.fstatSync(source.handle.fd, { bigint: true }));
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
await source.handle.close().catch(() => undefined);
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
if (params.maxBytes !== undefined && source.stat.size > params.maxBytes) {
|
|
61
|
+
throw new FsSafeError("too-large", `file exceeds limit of ${params.maxBytes} bytes (got ${source.stat.size})`);
|
|
62
|
+
}
|
|
63
|
+
let metadata;
|
|
64
|
+
try {
|
|
65
|
+
metadata = params.preserveMetadata ? captureCopyMetadata(source.handle.fd, sourceIdentity) : undefined;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
throw normalizePinnedWriteError(error);
|
|
69
|
+
}
|
|
70
|
+
const sourceAdmission = params.admitSource?.(sourceIdentity, source.realPath);
|
|
71
|
+
const verifySource = async () => {
|
|
72
|
+
params.signal?.throwIfAborted();
|
|
73
|
+
try {
|
|
74
|
+
sourceAdmission?.verify();
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
throw new MutationAuthorityError(error);
|
|
78
|
+
}
|
|
79
|
+
if (typeof params.source !== "string")
|
|
80
|
+
await params.source.root.stat(".");
|
|
81
|
+
assertCopySourceCurrent(source, sourceIdentity);
|
|
82
|
+
};
|
|
83
|
+
const mode = sourceAdmission?.mode ?? params.mode ?? (params.preserveSourceMode ? Number(sourceIdentity.mode & 4095n) : undefined);
|
|
84
|
+
await copyInputInRoot(root, params, {
|
|
85
|
+
kind: "file", handle: source.handle, size: source.stat.size, clone,
|
|
86
|
+
signal: params.signal, metadata, verifySource,
|
|
87
|
+
}, mode, () => assertCopySourceCurrent(source, sourceIdentity));
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
await source.handle.close().catch(() => { });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function copyInputInRoot(root, params, input, mode, verifyAdmission = input.verifySource) {
|
|
94
|
+
if (mode !== undefined && (!Number.isInteger(mode) || mode < 0 || mode > 0o7777)) {
|
|
95
|
+
throw new FsSafeError("invalid-path", "invalid copy mode");
|
|
96
|
+
}
|
|
97
|
+
await serializePathWrite(rootWriteQueueKey(root, params.relativePath), async () => {
|
|
98
|
+
const pinned = await resolvePinnedWriteTargetInRoot(root, params.relativePath, mode, params.denyMutations, params.overwrite !== false, params.mutationSymlinks);
|
|
99
|
+
await serializePathWrite(pinned.targetPath, async () => {
|
|
100
|
+
await verifyAdmission();
|
|
101
|
+
const observer = createCopyPublicationObserver(pinned.targetPath, params.onDestinationPublished);
|
|
102
|
+
try {
|
|
103
|
+
await runPinnedWriteHelper({
|
|
104
|
+
rootPath: pinned.rootReal, relativeParentPath: pinned.relativeParentPath, basename: pinned.basename,
|
|
105
|
+
mkdir: params.mkdir !== false, mode: pinned.mode, overwrite: params.overwrite !== false,
|
|
106
|
+
rejectFinalSymlink: params.mutationSymlinks !== undefined, maxBytes: params.maxBytes,
|
|
107
|
+
sync: params.durable !== false,
|
|
108
|
+
assertBeforeMutation: params.signal || params.assertBeforeMutation ? () => {
|
|
109
|
+
if (params.signal?.aborted)
|
|
110
|
+
throw new MutationAuthorityError(params.signal.reason);
|
|
111
|
+
params.assertBeforeMutation?.();
|
|
112
|
+
} : undefined,
|
|
113
|
+
verifyPublished: params.verifyPublished, onPublished: observer.onPublished, input,
|
|
114
|
+
rootIdentity: root.rootIdentity, mutationAdmission: pinned.mutationAdmission,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
observer.rethrowObserverFailure(error);
|
|
119
|
+
if (params.signal?.aborted && error === params.signal.reason)
|
|
120
|
+
throw error;
|
|
121
|
+
if (isAlreadyExistsError(error))
|
|
122
|
+
throw new FsSafeError("already-exists", "copy destination already exists", { cause: error });
|
|
123
|
+
throw normalizePinnedWriteError(error);
|
|
124
|
+
}
|
|
125
|
+
await input.verifySource();
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import type { FileHandle } from "node:fs/promises";
|
|
3
3
|
import { type AnyAsyncDirectoryGuard } from "./directory-guard.js";
|
|
4
|
-
import { type
|
|
4
|
+
import { type NativeBinding } from "./native.js";
|
|
5
5
|
import { type RootContext } from "./root-context.js";
|
|
6
6
|
import type { RootWritePathSelection, RetainedRootWriteSelection } from "./root-write-admission.js";
|
|
7
7
|
import type { WritableOpenResult } from "./root-impl.js";
|
|
8
8
|
import type { RootOpenWritableOptions } from "./root-options.js";
|
|
9
|
+
import { type Creation } from "./root-native-creation-path.js";
|
|
10
|
+
export { probeNativeCreationPath } from "./root-native-creation-path.js";
|
|
9
11
|
export type OpenedWritableFileInRoot = {
|
|
10
12
|
opened: WritableOpenResult;
|
|
11
13
|
identity: fs.BigIntStats;
|
|
@@ -28,18 +30,12 @@ export type MissingWritableFileInRoot = {
|
|
|
28
30
|
parentGuard: AnyAsyncDirectoryGuard;
|
|
29
31
|
writeSelection?: RootWritePathSelection;
|
|
30
32
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
target: string;
|
|
35
|
-
mkdir: boolean;
|
|
36
|
-
private?: boolean;
|
|
37
|
-
policy?: PinnedMutationPolicySnapshot;
|
|
38
|
-
resolveCurrent(): Promise<string>;
|
|
39
|
-
assertBeforeMutation?: () => void;
|
|
40
|
-
originalPath?: string;
|
|
41
|
-
};
|
|
33
|
+
export declare function isNativeCreateCollision(error: unknown): boolean;
|
|
34
|
+
/** Admit only an ordinary direct child; aliases keep the full resolver. */
|
|
35
|
+
export declare function tryMkdirNativeDirectChild(root: RootContext, relativePath: string): boolean;
|
|
42
36
|
export declare function tryMkdirRootNative(params: Creation): Promise<boolean>;
|
|
37
|
+
export declare function verifyMkdirDirectory(binding: NativeBinding, fd: number, pathname: string): void;
|
|
38
|
+
export declare function ensureNativeRootCurrent(root: RootContext): void;
|
|
43
39
|
export declare function tryOpenCreateRootNative(params: Creation & {
|
|
44
40
|
flags: number;
|
|
45
41
|
existingFlags: number;
|
|
@@ -49,4 +45,3 @@ export declare function tryOpenCreateRootNative(params: Creation & {
|
|
|
49
45
|
cleanupCreated(): Promise<void>;
|
|
50
46
|
releaseCreationParent(): void;
|
|
51
47
|
}>;
|
|
52
|
-
export {};
|