Skip to content

Commit bf96e5d

Browse files
committed
fix(atomic): recheck move authorization before rename
1 parent 754f920 commit bf96e5d

17 files changed

Lines changed: 285 additions & 28 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.7.2 - 2026-09-01
4+
5+
- Add `movePathWithCopyFallback({ assertBeforeRename })` to synchronously recheck caller-owned authorization immediately before direct or staged rename, preserving refusal errors and rejecting asynchronous callbacks without publishing the move.
6+
37
## 0.7.1 - 2026-09-01
48

59
### Highlights

‎Cargo.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/atomic.md‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,40 @@ throws `ESTALE` before commit when possible. If the destination has already
209209
been committed, cleanup still preserves the changed source entries and throws
210210
`ESTALE`.
211211

212+
### Final rename authorization
213+
214+
Pass `assertBeforeRename` when a move depends on a revocable lease or another
215+
caller-owned authorization. The helper captures this callback when called and
216+
runs it synchronously after asynchronous preparation and directory checks,
217+
immediately before each rename is dispatched:
218+
219+
```ts
220+
type MovePathWithCopyFallbackOptions = {
221+
from: string;
222+
sourceHardlinks?: "allow" | "reject";
223+
to: string;
224+
assertBeforeRename?: () => void;
225+
};
226+
```
227+
228+
Throw to refuse publication. The original error is propagated, including errors
229+
with `EXDEV` or `EPERM` codes; an authorization failure never starts a copy
230+
fallback. A genuine rename failure may still require a second authorization
231+
check before publishing the staged copy.
232+
233+
The callback must return `undefined` synchronously. Returning a Promise, thenable,
234+
or any other value refuses the rename with a `TypeError`; rejected asynchronous
235+
results are consumed without authorizing the operation. Perform asynchronous
236+
policy checks before calling the helper and use this callback to recheck the
237+
current owner at the mutation boundary.
238+
239+
A refused rename leaves the source and destination unchanged; any private
240+
staged copy follows the helper's normal cleanup. The check does not cancel an
241+
already-dispatched rename or make an external lease store atomic with the
242+
filesystem. Cleanup after a successful move retains the existing source-identity
243+
checks. Omitting the
244+
callback preserves the usual move behavior.
245+
212246
## Difference from `root()`
213247

214248
| `Root` methods | `atomic` helpers |

‎native/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fs-safe-native"
3-
version = "0.7.1"
3+
version = "0.7.2"
44
edition = "2024"
55
license = "MIT"
66
repository = "https://github.com/openclaw/fs-safe"

‎native/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openclaw/fs-safe-native-build",
3-
"version": "0.7.1",
3+
"version": "0.7.2",
44
"description": "Private build workspace for the native bindings bundled by @openclaw/fs-safe.",
55
"private": true,
66
"license": "MIT",

‎package.json‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openclaw/fs-safe",
3-
"version": "0.7.1",
3+
"version": "0.7.2",
44
"description": "Capability-style filesystem roots for Node.js apps that handle untrusted relative paths.",
55
"keywords": [
66
"filesystem",
@@ -149,13 +149,13 @@
149149
"crabbox:warmup": "crabbox warmup"
150150
},
151151
"optionalDependencies": {
152-
"@openclaw/fs-safe-darwin-arm64": "0.7.1",
153-
"@openclaw/fs-safe-darwin-x64": "0.7.1",
154-
"@openclaw/fs-safe-linux-arm64-gnu": "0.7.1",
155-
"@openclaw/fs-safe-linux-arm64-musl": "0.7.1",
156-
"@openclaw/fs-safe-linux-x64-gnu": "0.7.1",
157-
"@openclaw/fs-safe-linux-x64-musl": "0.7.1",
158-
"@openclaw/fs-safe-win32-x64-msvc": "0.7.1",
152+
"@openclaw/fs-safe-darwin-arm64": "0.7.2",
153+
"@openclaw/fs-safe-darwin-x64": "0.7.2",
154+
"@openclaw/fs-safe-linux-arm64-gnu": "0.7.2",
155+
"@openclaw/fs-safe-linux-arm64-musl": "0.7.2",
156+
"@openclaw/fs-safe-linux-x64-gnu": "0.7.2",
157+
"@openclaw/fs-safe-linux-x64-musl": "0.7.2",
158+
"@openclaw/fs-safe-win32-x64-msvc": "0.7.2",
159159
"jszip": "^3.10.1",
160160
"tar": "7.5.22"
161161
},

‎packages/darwin-arm64/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openclaw/fs-safe-darwin-arm64",
3-
"version": "0.7.1",
3+
"version": "0.7.2",
44
"description": "macOS arm64 native binding for @openclaw/fs-safe.",
55
"license": "MIT",
66
"author": "OpenClaw Team <[email protected]>",

‎packages/darwin-x64/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openclaw/fs-safe-darwin-x64",
3-
"version": "0.7.1",
3+
"version": "0.7.2",
44
"description": "macOS x64 native binding for @openclaw/fs-safe.",
55
"license": "MIT",
66
"author": "OpenClaw Team <[email protected]>",

‎packages/linux-arm64-gnu/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openclaw/fs-safe-linux-arm64-gnu",
3-
"version": "0.7.1",
3+
"version": "0.7.2",
44
"description": "Linux arm64 glibc native binding for @openclaw/fs-safe.",
55
"license": "MIT",
66
"author": "OpenClaw Team <[email protected]>",

‎packages/linux-arm64-musl/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openclaw/fs-safe-linux-arm64-musl",
3-
"version": "0.7.1",
3+
"version": "0.7.2",
44
"description": "Linux arm64 musl native binding for @openclaw/fs-safe.",
55
"license": "MIT",
66
"author": "OpenClaw Team <[email protected]>",

0 commit comments

Comments
 (0)