Skip to content

C4-2: Implement Rename via CopyObject and DeleteObject #164

Closed

Description

@scttfrdmn

Summary

Implement Rename so mv works on a mount. S3 has no native rename for general-purpose
buckets, so this is CopyObject + DeleteObject, recursive for directory prefixes.

Background

Rename is absent from internal/fuse/filesystem.go. It is already declared in
internal/filesystem/interface.go, implemented only by a test mock.

RenameObject is not usable here. The 2026 S3 RenameObject API is restricted to
directory buckets (S3 Express One Zone), and object annotations — which the attribute-storage
work depends on — are unsupported on directory buckets. The two features are mutually
exclusive, so general-purpose buckets must use copy-then-delete. RenameObject is worth
keeping as an optional fast path behind capability detection, but it cannot be the primary
implementation.

This is the least atomic operation in the milestone and the acceptance criteria should reflect
that honestly rather than implying POSIX rename semantics.

Implementation

Single file — CopyObject to the new key, then DeleteObject the old one. Preserve
metadata, storage class, and Content-Encoding through the copy; losing Content-Encoding
here would reintroduce the corruption class fixed in #153.

Directory — list the prefix and copy each object under the new prefix, then delete the old
ones. Two hard constraints:

  • Objects above 5 GB cannot use single-part CopyObject — it fails with an
    InvalidRequest. Those need multipart copy (UploadPartCopy). Detect via HeadObject size
    and route accordingly.
  • A large directory rename is not atomic and can fail midway. Do not attempt a
    transactional illusion. Delete each source object only after its copy succeeds, so a partial
    failure leaves both trees intact rather than losing data, and return the error.

POSIX expects rename-over-existing to replace the destination silently. Match that. Invalidate
cache and buffer entries for both source and destination paths.

Acceptance Criteria

  • mv a b renames a single file; content, metadata, and Content-Encoding are preserved
  • Renaming over an existing file replaces it
  • Renaming a directory moves all objects beneath it
  • An object larger than 5 GB is renamed via multipart copy
  • A partial directory-rename failure leaves source objects intact — no data loss
  • Cache and buffer are invalidated for both paths
  • Renaming a nonexistent path returns ENOENT
  • Non-atomicity of directory rename is documented in the operations docs
  • go test -race ./internal/fuse/... passes
  • AWS_PROFILE=aws AWS_REGION=us-west-2 go test -race -tags=integration ./internal/fuse/... passes

Dependencies

Depends on #163 (shares delete-path cache invalidation). Needs no persisted attributes.

Activity

  1. added
    type: enhancement
    priority: high
    area: fuse
    on Jul 30, 2026
  2. added
    effort: medium
    on Aug 3, 2026
  3. scttfrdmn commented on Aug 3, 2026

    @scttfrdmn
    OwnerAuthor

    Depends on #163. Rename here is CopyObject + DeleteObject, and DirectoryNode.Unlink currently returns EROFS (internal/fuse/filesystem.go:628) — so the delete half of rename has no working implementation to call. Do #163 first.

    Worth noting for whoever picks this up: RenameObject (2026) is not usable as a shortcut. It is directory-bucket/Express One Zone only, and object annotations are unsupported on directory buckets, so the two features are mutually exclusive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: fuseeffort: mediumpriority: hightype: enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions