Skip to content

feat(cli): 支持创建目录和移动远端文件 / add remote mkdir and move - #487

Open
Jinghao-coding wants to merge 4 commits into
raids-lab:mainfrom
Jinghao-coding:codex/issue-481-file-mkdir-move
Open

feat(cli): 支持创建目录和移动远端文件 / add remote mkdir and move#487
Jinghao-coding wants to merge 4 commits into
raids-lab:mainfrom
Jinghao-coding:codex/issue-481-file-mkdir-move

Conversation

@Jinghao-coding

@Jinghao-coding Jinghao-coding commented Jul 25, 2026

Copy link
Copy Markdown
Member

中文

变更内容

  • 新增 crater file mkdir <remote-path>,在 userpublicaccount 普通用户逻辑空间内创建单个远端目录。
  • 新增 crater file mv <source> <destination>,支持移动单个文件或目录。
  • storage service 为 MKCOL 和 move 增加统一的 JWT、路径、权限与授权根校验,并补充稳定的 40404 资源不存在错误码。
  • move 默认且始终拒绝覆盖;仅在底层文件系统支持原子 no-clobber rename 时执行,不支持时安全失败。
  • MKCOL 保留 WebDAV 管理员路径兼容,最终目录权限固定为 0777,Unix 下通过目录 FD 与 O_NOFOLLOW 避免跟随末端 symlink。
  • 补齐英文/中文输出、JSON 输出、shell completion、命令文档、CLI Skill、单元测试、快照测试与跨平台构建检查。

用户影响

普通用户现在可以只通过 CLI 创建远端目录,并安全移动一个远端文件或目录;父目录不会被自动创建,目标已存在时不会被覆盖。

验证

  • backend: go test -race ./internal/storage -count=1
  • backend: go vet ./internal/storage ./cmd/storage-server
  • backend: make lint(full + changed,均为 0 issues)
  • backend: storage tests cross-compiled for linux/amd64, linux/arm64, freebsd/amd64, windows/amd64
  • cli: go test -race ./cmd ./internal/api ./test/snapshots/file -count=1
  • cli: go vet ./...
  • cli: go build
  • frontend: pnpm exec tsc --noEmit
  • GitHub PR checks:backend、storage、frontend 的 lint 与 build 共 6 项全部通过。
  • 真实登录后的本地 storage-server + Vite proxy 联调:目录创建、文件移动、目录移动、目标冲突、后代路径拒绝均符合预期。

#481 CLI 联调截图


English

What changed

  • Added crater file mkdir <remote-path> for creating exactly one remote directory under the ordinary-user user, public, or account logical roots.
  • Added crater file mv <source> <destination> for moving one remote file or directory.
  • Added consistent JWT, path, permission, and authorized-root enforcement for MKCOL and move in the storage service, together with the stable 40404 not-found code.
  • Move never overwrites. It runs only when the backing filesystem provides atomic no-clobber rename semantics and fails closed otherwise.
  • Preserved WebDAV admin-path compatibility for MKCOL. New directories end with mode 0777; Unix uses a directory descriptor and O_NOFOLLOW to avoid following a final symlink.
  • Added bilingual output, JSON output, shell completion, command docs, the CLI Skill, unit tests, snapshots, and cross-platform build coverage.

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=1
  • backend: go vet ./internal/storage ./cmd/storage-server
  • backend: make lint (full + changed, both 0 issues)
  • backend: storage tests cross-compiled for linux/amd64, linux/arm64, freebsd/amd64, windows/amd64
  • cli: go test -race ./cmd ./internal/api ./test/snapshots/file -count=1
  • cli: go vet ./...
  • cli: go build
  • frontend: pnpm exec tsc --noEmit
  • All six GitHub PR checks pass: backend, storage, and frontend lint/build.
  • Live local integration through an authenticated storage-server and Vite proxy covered directory creation, file move, directory move, destination conflict, and descendant-path rejection.

Issue #481 CLI integration

Depends on #486.

Closes #481.

Copilot AI review requested due to automatic review settings July 25, 2026 20:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@Jinghao-coding Jinghao-coding changed the title feat(cli): add remote directory creation and move feat(cli): 支持创建目录和移动远端文件 / add remote mkdir and move Jul 25, 2026
@Jinghao-coding
Jinghao-coding force-pushed the codex/issue-481-file-mkdir-move branch from 32d00cc to ac19753 Compare July 28, 2026 14:47
@Jinghao-coding
Jinghao-coding force-pushed the codex/issue-481-file-mkdir-move branch from ac19753 to abb7572 Compare July 30, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cli): 支持创建目录和移动远端文件 / add remote mkdir and move

2 participants