syncthing/lib
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
..
auto all: Update license url to https (ref #3976) 2017-02-09 08:04:16 +01:00
beacon lib/beacon: Don't exit after a single write failure (fixes #4414) 2017-10-12 07:13:44 +00:00
config lib/config, lib/discover: Support new discovery cluster (ref #4618) 2018-01-05 14:18:32 +00:00
connections vendor: Move back to upstream KCP (fixes #4407) 2017-12-27 11:33:12 +00:00
db lib/db: Keep folder meta data persistently in db (fixes #4400) 2017-12-14 09:51:17 +00:00
dialer lib/dialer: Register dialer for socks URL scheme (fixes #4515) 2017-12-08 12:04:43 +00:00
discover lib/config, lib/discover: Support new discovery cluster (ref #4618) 2018-01-05 14:18:32 +00:00
events lib/events: Fix unmarshaling of EventType 2017-11-22 23:25:55 +00:00
fs lib/scanner: Fix UTF-8 normalization on ZFS (fixes #4649) 2018-01-05 18:11:09 +00:00
ignore lib/ignore: Consistent behaviour for nil *Matcher 2017-09-06 06:39:18 +00:00
logger gui: Add debug tab to settings (ref #2644) 2017-12-24 22:26:05 +00:00
model lib/model: Fix panic when auto-accepting existing paused folder (fixes #4636) 2018-01-03 07:42:25 +00:00
nat lib/upnp: Each service is it's own NAT device 2017-12-30 19:16:08 +00:00
osutil lib/osutil, lib/scanner: Run symlink test on Windows when possible 2017-11-25 21:49:53 +00:00
pmp all: Update license url to https (ref #3976) 2017-02-09 08:04:16 +01:00
protocol vendor: Move back to upstream KCP (fixes #4407) 2017-12-27 11:33:12 +00:00
rand all: Update license url to https (ref #3976) 2017-02-09 08:04:16 +01:00
rc test: Mend tests for latest event changes etc 2017-11-13 00:25:07 +01:00
relay all: Update license url to https (ref #3976) 2017-02-09 08:04:16 +01:00
scanner lib/scanner: Fix UTF-8 normalization on ZFS (fixes #4649) 2018-01-05 18:11:09 +00:00
sha256 cmd/syncthing, lib/sha256: Skip CPU benchmarks when user decided (fixes #4348) 2017-09-06 06:55:47 +00:00
signature all: Update license url to https (ref #3976) 2017-02-09 08:04:16 +01:00
stats all: Update license url to https (ref #3976) 2017-02-09 08:04:16 +01:00
sync cmd/syncthing: Clean up deadlock envvars 2017-12-13 19:40:12 +00:00
tlsutil lib/tlsutil: Remove undesired bufio from UnionedConnection (ref #4245) 2017-08-31 07:34:48 +00:00
upgrade lib/upgrade: 0.x to 1.0 is a minor upgrade 2017-06-25 14:17:43 +00:00
upnp lib/upnp: Each service is it's own NAT device 2017-12-30 19:16:08 +00:00
util lib/config, lib/model: Tweaks to the auto accept feature 2017-12-07 08:33:32 +00:00
versioner cmd/syncthing: UI for version restoration (fixes #2599) (#4602) 2018-01-01 15:39:23 +01:00
watchaggregator lib/watchaggregator: Don't care about timings during testing on darwin 2017-11-10 17:05:31 +00:00
weakhash all: Convert folders to use filesystem abstraction 2017-08-19 14:36:56 +00:00