Skip to content

bisync: handle unicode normalization consistently #7270

Closed

Description

@nielash

Bisync sometimes normalizes NFD to NFC and sometimes does not, causing errors in some scenarios (particularly for users of macOS). See https://forum.rclone.org/t/bisync-question/41434/12

Here is a bare-minimum case to reproduce:

% rclone touch NFD/ö 
% rclone touch NFC/ö
% rclone bisync NFD NFC --resync
2023/09/02 18:23:08 NOTICE: bisync is EXPERIMENTAL. Don't use in production!
% rclone bisync NFD NFC         
2023/09/02 18:23:17 NOTICE: bisync is EXPERIMENTAL. Don't use in production!
2023/09/02 18:23:17 ERROR : -          Path1 file not found in Path2       - ö
2023/09/02 18:23:17 ERROR : -          Path2 file not found in Path1       - ö
2023/09/02 18:23:17 ERROR : Bisync critical error: path1 and path2 are out of sync, run --resync to recover
2023/09/02 18:23:17 ERROR : Bisync aborted. Must run --resync to recover.
% 

As background context: most of the world uses NFC, but macOS prefers NFD for some reason, and will sometimes (but not always) convert NFC filenames to NFD invisibly. (See also: #7072)

Rclone's copy and sync commands (including the ones used by bisync under-the-hood) automatically normalize to NFC, unless --no-unicode-normalization is specified. This is why you can usually rclone sync between mac and non-mac without issue -- rclone will recognize the NFC and NFD versions as the same filename.

The trouble is that there are three places where bisync does NOT do this:

  1. When building the list of files that need to be transferred during --resync
  2. When building the list of deltas during a non-resync, but only for so-called "Unusual sync checks"
  3. When comparing Path1 to Path2 during --check-sync

1 and 2 end up being (mostly) harmless, because although it will try to copy the NFC and NFD versions as different files, the underlying copy function it calls is smart enough to realize they are the same file. It will therefore leave the files alone (if already equal) or update one of them (if not equal), but never create a duplicate.

3 is where the problem is most visible. Because --check-sync never normalizes, it thinks the NFC and NFD versions are different files. It therefore thinks something went wrong during the bisync run, because at the end of the run the Path1 file list does not exactly match Path2. Accordingly, it throws a critical error. (--check-sync is true by default, but can be overridden with --check-sync=false.)

The long-term solution is probably that bisync should support normalization in the same manner as sync (i.e. always normalize when comparing between paths, unless --no-unicode-normalization has been specified.) In the mean time, as a short-term solution, the issue can be bypassed by using --check-sync=false.

Also worth noting: in #5679 (comment) we are contemplating whether --check-sync should perhaps just be replaced by outsourcing it to the more robust rclone check, which duplicates a lot of the same functionality, but does it better. That may ultimately be the answer here too, at least for item 3 (--check-sync). But I think items 1 and 2 do still need to be addressed regardless, as they are (at best) misleading to users (for instance, dry runs indicate that files will be transferred when they are not in fact new/changed and won't really be transferred.)

One more note: it seems that macOS will accept NFC filenames when created via terminal commands, but not when created via apps or Finder. This is why we don't tend to see these issues at first with files synced from cloud to mac via rclone, but the same files could present issues later if edited by an app or Finder. (This is also why rclone touch NFC/ö in the above repro will work, even on mac.)

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Activity

  1. added this to the Known Problem milestone on Sep 3, 2023
  2. self-assigned this
    on Sep 3, 2023
  3. modified the milestones: Known Problem, Soon on Sep 5, 2023
  4. 23 remaining items

  5. added 5 commits that reference this issue on Dec 4, 2023
    89526d7
    eb23429
    3469c3d
  6. added a commit that references this issue on Jan 20, 2024
    98f539d
  7. added a commit that references this issue on Jan 26, 2024
    f7f4651
  8. moved this to Done in bisyncon Aug 20, 2024
  9. added 2 commits that reference this issue on Jul 20, 2026
    14e1c0a
    a428a14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

  • Status
    Done

Relationships

None yet

Development

No branches or pull requests

Issue actions