Skip to content

fix: rename a file to a change of case only where rclone can - #8

Merged
SyscallBrain merged 2 commits into
mainfrom
fix/case-only-file-rename
Dec 1, 2026
Merged

SyscallBrain merged 2 commits into
mainfrom
fix/case-only-file-rename

Conversation

@SyscallBrain

@SyscallBrain SyscallBrain commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

What and why

On macOS, renaming notes.txt to Notes.txt was refused with "“Notes.txt” already exists here": the rename guard stats the new name, and a case-insensitive filesystem answers with the file itself — macOS's local backend answers with the name it was asked for, so the file looks like another entry.

The folder's real names tell the two apart. An entry that is not the renamed one and matches the new name in whatever case keeps the "already exists" refusal, which now also guards a Dropbox or OneDrive folder holding two files that differ only in case. Where nothing else matches, the rename goes ahead only when rclone itself knows the filesystem ignores case (operations/fsinfo, Features.CaseInsensitive, present since 1.68.0): it then moves the file through a temporary name, as on macOS. On Linux rclone reports FAT, exFAT and SMB mounts as case-sensitive however they behave, and such a move deletes the file instead of renaming it (the danger in #3 as it stood, verified with rclone mount --vfs-case-insensitive): the refusal now explains that and suggests a rename through another name, which the test walks.

Tests: a clash of two files on a case-sensitive filesystem stays refused; through CaseInsensitiveDir::over, the rename succeeds where rclone knows it can (macOS) and is refused with the file intact where it cannot (the Linux FUSE mount); the two-step rename the message suggests works on both. The suite passes against rclone 1.68.0 and 1.75.2 on Linux; the macOS branch of the fsinfo test runs on a Mac.

The test wrapper also sets RCLONE_LOCAL_NO_CLONE=true (from #3): on macOS rclone clones a local-to-local copy, which ignores the bandwidth limit two tests throttle one with.

Closes #3: the report and the macOS diagnosis are Josh Kerr's; this follows the approach agreed in that pull request's review.

Checklist

  • cargo fmt --check, cargo clippy --all-targets -- -D warnings and cargo test pass
  • Tests cover the change (no UI or snapshot changes)
  • The book (book/src/) is updated if keys, options or behaviour changed (not needed: nothing documented changed)
  • The change has a line under [Unreleased] in CHANGELOG.md

Summary by CodeRabbit

  • Bug Fixes
    • Case-only file renames now work on filesystems recognized as case-insensitive. On filesystems reported as case-sensitive, these renames are refused with an explanation of the risk and a suggestion to rename through a temporary name.
    • Renames are refused when a separate file already exists with the requested name, preventing accidental overwrites.

Renaming notes.txt to Notes.txt was refused as a name already in use
wherever the filesystem ignores case: the guard stats the new name, the
entry itself answers, and macOS's local backend answers with the name it
was asked for, so the file looks like another entry.

The folder's real names tell the two apart: an entry that is not the
renamed one and matches the new name, in whatever case, keeps the
refusal. Where nothing else does, the rename goes ahead only when rclone
knows the filesystem ignores case (operations/fsinfo,
Features.CaseInsensitive): it then moves the file through a temporary
name, as on macOS. On Linux it reports FAT, exFAT and SMB mounts as
case-sensitive however they behave, and the move would delete the file
instead of renaming it: the refusal now says so and suggests a rename
through another name, which works.

The macOS failure was reported and diagnosed by Josh Kerr in #3. That
approach, refusing only when the listing holds an entry of the exact
new name, would also have let the move land on a Dropbox or OneDrive
folder that holds two files differing only in case.

The test wrapper also sets RCLONE_LOCAL_NO_CLONE=true: on macOS rclone
clones a local-to-local copy, which ends at once whatever the bandwidth
limit, and the tests that need a copy still running throttle one. Older
rclones ignore the unknown variable.
@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 45 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cbf3fc99-a442-4eee-9ac7-5a670ca44e6c
Commits

Reviewing files that changed from the base of the PR and between bb9ff55 and 61a5169.

Files selected for processing: 1

  • tests/rc_client.rs

No actionable comments were generated in the recent review.

Walkthrough

The RC backend now checks filesystem case behavior and directory entries when handling case-only file renames. Tests cover rename outcomes and collisions. The test wrapper disables local cloning, and the Unreleased changelog describes the behavior.

Changes: Case-only file renames

Layer / File(s) Summary
Filesystem feature and rename handling
src/rc/types.rs, src/backend/rc.rs
Adds types for the operations/fsinfo response. The RC backend checks directory entries for a case-only file rename and uses rclone’s case_insensitive feature to decide whether to allow it.
Rename tests and release note
tests/rc_backend.rs, tests/common/mod.rs, CHANGELOG.md
Tests check case-only rename outcomes, collisions, and file contents. The test wrapper sets RCLONE_LOCAL_NO_CLONE=true. The Unreleased changelog describes the rename behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

Merge Risk: Low · previous review bb9ff

Case-only file renames now proceed only when rclone reports the filesystem as case-insensitive, and the rename is refused otherwise. I found no defect in the changed logic, but the CI check for this PR failed and its cause is unconfirmed. Confirm that check passes before merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix: rename a file to a change of case only where rclone can" describes the main change: case-only file renames are now allowed only when rclone reports a case-insensitive filesystem. It is…
Description check Passed The description follows the template. The 'What and why' section explains the problem (macOS case-only rename refused), the approach, the Linux FAT/exFAT/SMB limitation, the tests run, and links the i…
Linked Issues check Passed Issue #3 coding requirements are met by the reviewed head.

1. Case-only file rename on macOS (#3): RcBackend::rename in src/backend/rc.rs now treats a clash as a case-only rename when the stat hi…
Out of Scope Changes check Passed All changed areas connect to issue #3 or to the PR's stated purpose:
- src/backend/rc.rs: the rename guard change and the fs_ignores_case helper call operations/fsinfo. These implement the case-…
Full details: Title check

Explanation

The title "fix: rename a file to a change of case only where rclone can" describes the main change: case-only file renames are now allowed only when rclone reports a case-insensitive filesystem. It is specific and matches the changeset (rc.rs rename logic, RcFsInfo/RcFeatures types, tests, and CHANGELOG entry). It is somewhat long and wordy, but it is clear and related to the main change.

Full details: Description check

Explanation

The description follows the template. The 'What and why' section explains the problem (macOS case-only rename refused), the approach, the Linux FAT/exFAT/SMB limitation, the tests run, and links the issue with 'Closes #3'. All four checklist items are present and marked. The book item is explained as not needed because no documented behaviour changed. The description is thorough and specific.

Full details: Linked Issues check

Explanation

Issue #3 coding requirements are met by the reviewed head.

  1. Case-only file rename on macOS (#3): RcBackend::rename in src/backend/rc.rs now treats a clash as a case-only rename when the stat hit has a different name, the rename is a file, the new name equals the old name ignoring case, and no other entry in the parent listing matches the new name ignoring case. Only that case passes the guard. On macOS, rclone reports Features.CaseInsensitive, so the code calls operations/movefile.
  2. Real clash still refused (#3): an entry other than the source that matches the new name in any case keeps the "already exists here" refusal. The summary says tests in tests/rc_backend.rs cover a case-sensitive clash of two files.
  3. Other renames unchanged (#3): the extra operations/list runs only when !is_dir and the names match ignoring case. The folder path keeps its earlier checks.
  4. Test-only change (#3): tests/common/mod.rs sets RCLONE_LOCAL_NO_CLONE=true in the isolated rclone environment, as the issue requests.

The PR narrows the issue's hedged expectation ("should also help" on Linux case-insensitive mounts). It refuses the rename where rclone reports case-sensitivity, and the issue does not state a firm Linux requirement, so this is not a failure.

Unresolved detail: the PR text says the rename "moves the file through a temporary name". The rename code at the reviewed head shows a direct operations/movefile call with no temporary name. The summary does not show that temporary-name handling is in rclone or elsewhere. The source-level evidence does not confirm that mechanism. The macOS behaviour depends on rclone and was verified by hand, not by this review.

Full details: Out of Scope Changes check

Explanation

All changed areas connect to issue #3 or to the PR's stated purpose:

  • src/backend/rc.rs: the rename guard change and the fs_ignores_case helper call operations/fsinfo. These implement the case-only rename behaviour.
  • src/rc/types.rs: adds RcFsInfo and RcFeatures for the operations/fsinfo response. This type supports the guard.
  • tests/rc_backend.rs: adds tests for the clash, the supported and refused case-only renames, and the two-step rename. These are supporting tests.
  • tests/common/mod.rs: sets RCLONE_LOCAL_NO_CLONE=true, which the issue requests.
  • CHANGELOG.md: adds an Unreleased line for the fix.

No change was found that is unrelated to the issue. The out-of-scope assessment is based on the summaries and the rename code shown at the reviewed head.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4da837a1-bf68-49b6-81f8-331b5ad8de28
Commits

Reviewing files that changed from the base of the PR and between baf246f and bb9ff55.

Files selected for processing: 5

  • CHANGELOG.md
  • src/backend/rc.rs
  • src/rc/types.rs
  • tests/common/mod.rs
  • tests/rc_backend.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

daemon_wrapper_excludes_inherited_credentials_and_remotes exec'd its
wrapper through Command::output, with no retry: with many tests writing
their own wrappers at once, a wrapper still open for writing in a child
another test forked but not yet exec'd made the exec fail with
"Text file busy", and the CI run flaked. Go through common::spawn,
which retries that error, as the fixtures already do.
@SyscallBrain
SyscallBrain merged commit 152c4a0 into main Dec 1, 2026
4 checks passed
@SyscallBrain
SyscallBrain deleted the fix/case-only-file-rename branch December 1, 2026 01:51
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.

1 participant