syncthing/lib/fs
Antony Male db03562d43 lib/scanner: Fix UTF-8 normalization on ZFS (fixes #4649)
It turns out that ZFS doesn't do any normalization when storing files,
but does do normalization "as part of any comparison process".

In practice, this seems to mean that if you LStat a normalized filename,
ZFS will return the FileInfo for the un-normalized version of that
filename.

This meant that our test to see whether a separate file with a
normalized version of the filename already exists was failing, as we
were detecting the same file.

The fix is to use os.SameFile, to see whether we're getting the same
FileInfo from the normalized and un-normalized versions of the same
filename.

One complication is that ZFS also seems to apply its magic to os.Rename,
meaning that we can't use it to rename an un-normalized file to its
normalized filename. Instead we have to move via a temporary object. If
the move to the temporary object fails, that's OK, we can skip it and
move on. If the move from the temporary object fails however, I'm not
sure of the best approach: the current one is to leave the temporary
file name as-is, and get Syncthing to syncronize it, so at least we
don't lose the file. I'm not sure if there are any implications of this
however.

As part of reworking normalizePath, I spotted that it appeared to be
returning the wrong thing: the doc and the surrounding code expecting it
to return the normalized filename, but it was returning the
un-normalized one. I fixed this, but it seems suspicious that, if the
previous behaviour was incorrect, noone ever ran afoul of it. Maybe all
filesystems will do some searching and give you a normalized filename if
you request an unnormalized one.

As part of this, I found that TestNormalization was broken: it was
passing, when in fact one of the files it should have verified was
present was missing. Maybe this was related to the above issue with
normalizePath's return value, I'm not sure. Fixed en route.

Kindly tested by @khinsen on the forum, and it appears to work.

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4646
2018-01-05 18:11:09 +00:00
..
basicfs.go lib/scanner: Fix UTF-8 normalization on ZFS (fixes #4649) 2018-01-05 18:11:09 +00:00
basicfs_test.go all: Add filesystem notification support 2017-10-20 14:52:55 +00:00
basicfs_unix.go all: Convert folders to use filesystem abstraction 2017-08-19 14:36:56 +00:00
basicfs_watch.go all: Add filesystem notification support 2017-10-20 14:52:55 +00:00
basicfs_watch_errors_linux.go all: Add filesystem notification support 2017-10-20 14:52:55 +00:00
basicfs_watch_errors_others.go all: Add filesystem notification support 2017-10-20 14:52:55 +00:00
basicfs_watch_eventtypes_fen.go all: Add filesystem notification support 2017-10-20 14:52:55 +00:00
basicfs_watch_eventtypes_inotify.go all: Add filesystem notification support 2017-10-20 14:52:55 +00:00
basicfs_watch_eventtypes_kqueue.go all: Add filesystem notification support 2017-10-20 14:52:55 +00:00
basicfs_watch_eventtypes_other.go all: Add filesystem notification support 2017-10-20 14:52:55 +00:00
basicfs_watch_eventtypes_readdcw.go all: Add filesystem notification support 2017-10-20 14:52:55 +00:00
basicfs_watch_test.go lib/fs: Prolong test timeout on darwin, hopefully fixing flakyness 2017-12-06 22:07:08 +00:00
basicfs_watch_unsupported.go all: Add filesystem notification support 2017-10-20 14:52:55 +00:00
basicfs_windows.go all: Convert folders to use filesystem abstraction 2017-08-19 14:36:56 +00:00
debug.go gui: Add debug tab to settings (ref #2644) 2017-12-24 22:26:05 +00:00
errorfs.go lib/scanner: Fix UTF-8 normalization on ZFS (fixes #4649) 2018-01-05 18:11:09 +00:00
filesystem.go lib/scanner: Fix UTF-8 normalization on ZFS (fixes #4649) 2018-01-05 18:11:09 +00:00
filesystem_test.go lib: Folder marker is now a folder 2017-09-02 05:52:38 +00:00
folding.go lib/fs: Add case insensitivity to MtimeFS 2017-11-17 12:10:16 +00:00
folding_test.go lib/fs: Add case insensitivity to MtimeFS 2017-11-17 12:10:16 +00:00
fsfileinfo_unix.go lib/fs: Handle deduplicated files on NTFS (fixes #1845) 2017-12-29 21:23:06 +00:00
fsfileinfo_windows.go lib/fs: Handle deduplicated files on NTFS (fixes #1845) 2017-12-29 21:23:06 +00:00
logfs.go all: Add filesystem notification support 2017-10-20 14:52:55 +00:00
lstat_broken.go lib/scanner: Use fs.Filesystem for all operations 2017-04-01 09:04:11 +00:00
lstat_regular.go lib/scanner: Use fs.Filesystem for all operations 2017-04-01 09:04:11 +00:00
mtimefs.go lib/fs: Add case insensitivity to MtimeFS 2017-11-17 12:10:16 +00:00
mtimefs_test.go lib/fs: Add case insensitivity to MtimeFS 2017-11-17 12:10:16 +00:00
tempname.go lib/scanner: Fix UTF-8 normalization on ZFS (fixes #4649) 2018-01-05 18:11:09 +00:00
tempname_test.go lib: Folder marker is now a folder 2017-09-02 05:52:38 +00:00
types.go all: Convert folders to use filesystem abstraction 2017-08-19 14:36:56 +00:00
util.go all: Add invalid/ignored files to global list, announce to peers (fixes #623) 2017-11-11 19:18:17 +00:00
walkfs.go all: Convert folders to use filesystem abstraction 2017-08-19 14:36:56 +00:00