feat(cli): 支持创建目录和移动远端文件 / add remote mkdir and move - #487
feat(cli): 支持创建目录和移动远端文件 / add remote mkdir and move#487Jinghao-coding wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: be88c9ba0f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if err := parent.Mkdir(name, mode); err != nil { | ||
| return err | ||
| } | ||
| return chmodCreatedStorageDirectory(parent, name, mode) |
There was a problem hiding this comment.
Clean up the directory when the final chmod fails
When the backing filesystem permits Mkdir but rejects the subsequent descriptor-based chmod—for example, on a mount with unsupported or restricted permission changes—this returns an error after the directory has already been created. The client therefore reports failure while leaving an entry with the umask-reduced mode behind, and retrying immediately produces an already-exists conflict. Roll back the newly created directory on this failure path, or otherwise avoid returning failure after committing the creation.
Useful? React with 👍 / 👎.
32d00cc to
ac19753
Compare
ac19753 to
abb7572
Compare
中文
变更内容
crater file mkdir <remote-path>,在user、public、account普通用户逻辑空间内创建单个远端目录。crater file mv <source> <destination>,支持移动单个文件或目录。40404资源不存在错误码。0777,Unix 下通过目录 FD 与O_NOFOLLOW避免跟随末端 symlink。用户影响
普通用户现在可以只通过 CLI 创建远端目录,并安全移动一个远端文件或目录;父目录不会被自动创建,目标已存在时不会被覆盖。
验证
backend: go test -race ./internal/storage -count=1backend: go vet ./internal/storage ./cmd/storage-serverbackend: make lint(full + changed,均为 0 issues)backend: storage tests cross-compiled for linux/amd64, linux/arm64, freebsd/amd64, windows/amd64cli: go test -race ./cmd ./internal/api ./test/snapshots/file -count=1cli: go vet ./...cli: go buildfrontend: pnpm exec tsc --noEmitEnglish
What changed
crater file mkdir <remote-path>for creating exactly one remote directory under the ordinary-useruser,public, oraccountlogical roots.crater file mv <source> <destination>for moving one remote file or directory.40404not-found code.0777; Unix uses a directory descriptor andO_NOFOLLOWto avoid following a final symlink.User impact
Ordinary users can now create a remote directory and safely move one remote file or directory entirely through the CLI. Parent directories are never created implicitly, and an existing destination is never overwritten.
Validation
backend: go test -race ./internal/storage -count=1backend: go vet ./internal/storage ./cmd/storage-serverbackend: make lint(full + changed, both 0 issues)backend: storage tests cross-compiled for linux/amd64, linux/arm64, freebsd/amd64, windows/amd64cli: go test -race ./cmd ./internal/api ./test/snapshots/file -count=1cli: go vet ./...cli: go buildfrontend: pnpm exec tsc --noEmitDepends on #486.
Closes #481.