Skip to content

sync: --fix-case flag to rename case insensitive dest - fixes #4854 - #7356

Closed
nielash wants to merge 2 commits into
rclone:masterfrom
nielash:fix-case
Closed

nielash wants to merge 2 commits into
rclone:masterfrom
nielash:fix-case

Conversation

@nielash

@nielash nielash commented Oct 9, 2023

Copy link
Copy Markdown
Contributor

What is the purpose of this change?

Before this change, a sync to a case insensitive dest (such as macOS / Windows) would not result in a matching filename if the source and dest had casing differences but were otherwise equal. For example, syncing hello.txt to HELLO.txt would result in the dest filename remaining HELLO.txt. Furthermore, --local-case-sensitive did not solve this, as it actually caused HELLO.txt to get deleted!

After this change, HELLO.txt is renamed to hello.txt to match the source, only if the --fix-case flag is specified. (The old behavior remains the default.)

One question I have... should this maybe be the default? Can we think of a reason that the old behavior would be preferable?

Also note that this does not address the related issues regarding dedupe, so perhaps #1133 or #2430 should be reopened.

Was the change discussed in an issue or in the forum before?

Many times (but not by me 😄 )

Checklist

  • I have read the contribution guidelines.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate.
  • All commit messages are in house style.
  • I'm done, this Pull Request is ready for review :-)

@ncw ncw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very nice feature :-)

See inline for some comments.

Comment thread fs/config/configflags/configflags.go Resolved
Comment thread fs/sync/sync.go Resolved
Comment thread fs/sync/sync_test.go Resolved
@nielash

nielash commented Oct 10, 2023

Copy link
Copy Markdown
Contributor Author

Thank you @ncw! You are right, and also I just realized an additional problem: syncing somedir/hello.txt to SOMEDIR/HELLO.txt will result in SOMEDIR/hello.txt (with dir names still not matching.) And I'm not sure if it's wise to move the dir while other goroutines could be working on files in the same dir. Do you have any suggestions on a clean solution? I can look into it more as well.

In the meantime, I am downgrading this PR to "draft" until I have a chance to revise.

@nielash
nielash marked this pull request as draft October 10, 2023 00:59
@nielash

nielash commented Oct 10, 2023

Copy link
Copy Markdown
Contributor Author

Actually I think maybe I figured it out. See if I'm on the right track with this: b13626b

Also, I think I found and fixed an existing bug in the process (I can break this into a separate commit if you prefer)

The tests pass everywhere but windows -- I will try to debug the windows-specific issue.

@ncw

ncw commented Oct 10, 2023

Copy link
Copy Markdown
Member

I added some comments!

If you separate the fix into a new commit that would be perfect. Or a new PR. You could make a failing test case which you make pass with the fix.

Before this change, changing the case of a file on a case insensitive remote
would fatally panic when `--dry-run` was set, due to `moveOrCopyFile`
attempting to access the non-existent `tmpObj` it (would normally have)
created. After this change, the panic is avoided by skipping this step during
a `--dry-run` (with the usual "skipped as --dry-run is set" log message.)
…4854

Before this change, a sync to a case insensitive dest (such as macOS / Windows)
would not result in a matching filename if the source and dest had casing
differences but were otherwise equal. For example, syncing `hello.txt` to
`HELLO.txt` would result in the dest filename remaining `HELLO.txt`.
Furthermore, `--local-case-sensitive` did not solve this, as it actually caused
`HELLO.txt` to get deleted!

After this change, `HELLO.txt` is renamed to `hello.txt` to match the source,
only if the `--fix-case` flag is specified. (The old behavior remains the
default.)
@nielash

nielash commented Oct 11, 2023

Copy link
Copy Markdown
Contributor Author

Fixed the windows-specific issue (for the record: it was this.)

@nielash
nielash marked this pull request as ready for review October 11, 2023 23:45
@nielash

nielash commented Jan 20, 2024

Copy link
Copy Markdown
Contributor Author

Closing as a dupe of #7410, which is now merged.

@nielash nielash closed this Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants