Repository navigation
vfs: fix unicode normalization on macOS - fixes #7072 - #7620
Conversation
|
Thank you very much for tackling this pesky issue with your PR! macOS users will be grateful:) I have been testing this feature for the last few days and it works like a charm with whatever NFC/NFD objects I throw at mount or remote. And everything is accessible on macOS using both terminal and Finder. This looks like true solution to years old problem with NFC/NFD on macOS. It works perfectly with both macFUSE and FUSE-T. No more any snake oil @ncw I see that #7072 is on |
|
Is there any issue stopping this change from being merged? |
|
I am sorry for pestering but as this is something causing issues in my daily rclone usage I keep a close eye on this possible fix. @ncw Has this change have a chance to be included in the next rclone release? Or is there still something needed required to do it? |
ncw
left a comment
There was a problem hiding this comment.
I think this looks sound :-)
I have some quibbles with the use of the global config though - see inline!
Thank you !
|
@ncw very helpful feedback, thank you! I think Another option is maybe to make a new VFS option, although it seems not ideal to have lots of options that kind of do the same thing (like we kind of already have with Whatever you think is best is fine with me 🙂 |
90dbe8b to
77c8596
Compare
|
Here's a revised version that addresses most of the feedback. The production code now uses |
ncw
left a comment
There was a problem hiding this comment.
I think your use of context in the tests is fine! The VFS doesn't have contexts and that is because the underlying Go interfaces don't take contexts which is unfortunate.
However on further reflection I think we should try to avoid having to change the context in the main code - see the notes I put inline! Reading it is fine and expected but changing it is not ideal.
77c8596 to
f0c5b6c
Compare
|
Makes sense! Here's a new version with this changed. |
Before this change, the VFS layer did not properly handle unicode normalization, which caused problems particularly for users of macOS. While attempts were made to handle it with various `-o modules=iconv` combinations, this was an imperfect solution, as no one combination allowed both NFC and NFD content to simultaneously be both visible and editable via Finder. After this change, the VFS supports `--no-unicode-normalization` (default `false`) via the existing `--vfs-case-insensitive` logic, which is extended to apply to both case insensitivity and unicode normalization form. This change also adds an additional flag, `--vfs-block-norm-dupes`, to address a probably rare but potentially possible scenario where a directory contains multiple duplicate filenames after applying case and unicode normalization settings. In such a scenario, this flag (disabled by default) hides the duplicates. This comes with a performance tradeoff, as rclone will have to scan the entire directory for duplicates when listing a directory. For this reason, it is recommended to leave this disabled if not needed. However, macOS users may wish to consider using it, as otherwise, if a remote directory contains both NFC and NFD versions of the same filename, an odd situation will occur: both versions of the file will be visible in the mount, and both will appear to be editable, however, editing either version will actually result in only the NFD version getting edited under the hood. `--vfs-block-norm-dupes` prevents this confusion by detecting this scenario, hiding the duplicates, and logging an error, similar to how this is handled in `rclone sync`.
f0c5b6c to
e637517
Compare
ncw
left a comment
There was a problem hiding this comment.
This looks great now - thank you :-)
I'll merge it.
What is the purpose of this change?
Before this change, the VFS layer did not properly handle unicode normalization, which caused problems particularly for users of macOS. While attempts were made to handle it with various
-o modules=iconvcombinations, this was an imperfect solution, as no one combination allowed both NFC and NFD content to simultaneously be both visible and editable via Finder.After this change, the VFS supports
--no-unicode-normalization(defaultfalse) via the existing--vfs-case-insensitivelogic, which is extended to apply to both case insensitivity and unicode normalization form.This change also adds an additional flag,
--vfs-block-norm-dupes, to address a probably rare but potentially possible scenario where a directory contains multiple duplicate filenames after applying case and unicode normalization settings. In such a scenario, this flag (disabled by default) hides the duplicates. This comes with a performance tradeoff, as rclone will have to scan the entire directory for duplicates when listing a directory. For this reason, it is recommended to leave this disabled if not needed. However, macOS users may wish to consider using it, as otherwise, if a remote directory contains both NFC and NFD versions of the same filename, an odd situation will occur: both versions of the file will be visible in the mount, and both will appear to be editable, however, editing either version will actually result in only the NFD version getting edited under the hood.--vfs-block-norm-dupesprevents this confusion by detecting this scenario, hiding the duplicates, and logging an error, similar to how this is handled inrclone sync.Was the change discussed in an issue or in the forum before?
Checklist