syncthing icon indicating copy to clipboard operation
syncthing copied to clipboard

Scan on absolute path creates incorrect absolute duplicate file infos

Open imsodin opened this issue 8 years ago • 17 comments

Reproducer

Run scan through rest API on a "virtually" absolute path that has no changed children, e.g. in my case folder root at /home/simon/test-sync and

curl -X POST -H "X-API-KEY: myapikey" "localhost:8385/rest/db/scan?folder=3vbey-elvwr&sub=/foo"

Result:
State counter increases and scanner debug log shows the problem:

[BXAEQ] 2018/03/10 11:09:21.303458 walk.go:101: DEBUG: Walk [/foo] 131072 Matcher/[nonreach* **/nonreach* nonreach*/** **/nonreach*/**]@0xc4202522d0
[BXAEQ] 2018/03/10 11:09:21.303837 walk.go:316: DEBUG: to hash: /foo File{Name:"/foo", Sequence:0, Permissions:0664, ModTime:2017-12-27 23:10:28.912229075 +0100 CET, Version:{[{BXAEQNX 1}]}, Length:741, Deleted:false, Invalid:false, NoPermissions:true, Blocks:[]}
[BXAEQ] 2018/03/10 11:09:21.303876 walk.go:186: DEBUG: real to hash: /foo
[BXAEQ] 2018/03/10 11:09:21.304035 walk.go:164: DEBUG: Walk progress done 3vbey-elvwr [/foo] 131072 Matcher/[nonreach* **/nonreach* nonreach*/** **/nonreach*/**]@0xc4202522d0

Expected:
No change at all.

Proposed fix

According to this comment the absolute path is valid, so it shouldn't throw an error, but scan normally removing the leading path separator.

imsodin avatar Mar 10 '18 10:03 imsodin

zomg

calmh avatar Mar 10 '18 10:03 calmh

Can we have a quick bugfix release for syncthing and syncthing android? Currently this makes my ignore list broken on my phone and I cannot sync between my pc and phone anymore at all. Ignore list broken? Yes. It seems this bug kills the ignore function too. Lets say i sync the android phone root folder /0/. In this folder there are two other syncthing folders which I sync too but they are both in the ignore list of the root folder /0/. sync instance for /0/ now has all the files added which actually were ignored before updating! They are not ignored anymore. Hope this could help a bit.

DrSchnagels avatar Mar 10 '18 12:03 DrSchnagels

@DrSchnagels The broken ignore patterns are rooted (/...), right? As a quick workaround you may be able to use non-rooted patterns, e.g. Android instead of /Android.

Btw, I don't see how any change between 0.14.44-0.14.45 should have had any influence on this problem, as far as I can see it should be present since introducing fs.

imsodin avatar Mar 10 '18 13:03 imsodin

Yeah this look like 0.14.37+

calmh avatar Mar 10 '18 13:03 calmh

@Catfriend1 It's not as far as I can see. Also conceptually there is no real connection. As @calmh wrote, at the moment it looks like this problem is present since 0.14.37. As it needs a specific condition (scan request on an absolute path by rest API) and problems came up on Android, it is possible that something changed there on this update.

EDIT: The culprit (well sort of) is https://github.com/syncthing/syncthing/pull/4671: Before that unifySubs([]string{"/foo"}) returned nil, now /foo.

imsodin avatar Mar 10 '18 14:03 imsodin

@imsodin Thanks. I removed all / in my ignore pattern for /0/. But now i get this error, but Telegram is not in the ignore file. I actually want the /0/Telegram to be synced with my pc. After removing the /, i dont get any connection at all between PC and phone.

[xsxs] 18:34:17 INFO: Established secure connection to yaya at 192.168.10.167:55034-192.168.10.149:22000/tcp-client (TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305) [xsxs] 18:34:17 INFO: Device yaya client is "syncthing v0.14.45" named "handy" at 192.168.10.167:55034-192.168.10.149:22000/tcp-client [xsxs] 18:34:17 INFO: Connection to yaya at 192.168.10.167:55034-192.168.10.149:22000/tcp-client closed: protocol error: index: "/Telegram": filename is invalid

DrSchnagels avatar Mar 10 '18 18:03 DrSchnagels

That's Syncthing correctly rejecting an index with a file with a path starting with /. It seems a bit extreme and useless to drop the connection due to that, but that's just a symptom. As the invalid file was already scanned, you cannot do anything except wait for the fixed version or remove the entire database on the Android device (i.e. full rescan).

imsodin avatar Mar 10 '18 20:03 imsodin

I did delete the syncthing apps database in the apps settings (delete app data). And reset the database within the app. This didnt work for our problem here and just very curiously, the app never rescaned. (reset database does not seem to work?). The scan was done without waiting at all... and that with more than 30 GB (OP5).

DrSchnagels avatar Mar 10 '18 21:03 DrSchnagels

Then it definitely didn't happen, no idea why. But I didn't think anyway - if you are still on the same version, the problem will just occur again anyway.

imsodin avatar Mar 10 '18 21:03 imsodin

I started getting those messages after 0.14.45 upgrade:

Connection to IDIDID_2 at IP_LOCAL:53347-IP_WAN:22047/relay-server closed: protocol error: index update: "/.stversions": filename is invalid
[IDIDID] 09:05:36 INFO: Completed initial scan of readwrite folder Andrey-PC-Music
[IDIDID] 09:07:23 INFO: Established secure connection to IDIDID_2 at IP_LOCAL:53471-IP_WAN:22047/relay-server (TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305)
[IDIDID] 09:07:23 INFO: Device IDIDID_2 client is "syncthing v0.14.45" named "DEVICE" at IP_LOCAL:53471-IP_WAN:22047/relay-server
[IDIDID] 09:07:25 INFO: Connection to IDIDID_2 at 10.0.0.5:53471-IP_WAN:22047/relay-server closed: protocol error: index update: "/.stversions": filename is invalid

The device is Win10x64, the remote device (IDIDID_2) is Android, all run ST v0.14.45

Does it belong to this issue?

scienmind avatar Mar 11 '18 07:03 scienmind

Yes.

(@imsodin) The culprit (well sort of) is #4671: Before that unifySubs([]string{"/foo"}) returned nil, now /foo.

So I guess if Android had been doing this all the time, it was fine up until 0.14.44 at which point it became a problem. Now those devices have index entries that are not accepted in other places. So we might want Android users upgraded to 0.14.46-rc.1 when we release that, with the fix for this.

calmh avatar Mar 11 '18 07:03 calmh

Hi @calmh ! Is there a way to roll back to 0.14.44 since that was working? Plus does this roll back has to happen only in Android devices to resolve the issue? Thanks!!!

papadopouloskyriakos avatar Mar 11 '18 22:03 papadopouloskyriakos

Only on android devices yes, no idea how to do the rollback though. You need to remove the database also when rolling back.

calmh avatar Mar 12 '18 10:03 calmh

@calmh maybe a complete uninstall, followed by the installation of 0.14.44 could do the trick? Are there .apk files available on Github or somewhere else of version 0.14.44 ? After installing I could disable the automatic updates somehow.... Thank you in advance!

papadopouloskyriakos avatar Mar 12 '18 17:03 papadopouloskyriakos

@llzzrrdd I can recommend using f-droid: https://f-droid.org/packages/com.nutomic.syncthingandroid/
Besides many other good reasons to use it, you can install old versions. There are also apks there if you really don't want to use it.

imsodin avatar Mar 12 '18 17:03 imsodin

@imsodin & @calmh thanks again! v0.14.43 found at f-droid has resolved the issue with Android! Everything seems to sync correctly now between windows(servers&workstations)/synology(linux)/android.

papadopouloskyriakos avatar Mar 12 '18 19:03 papadopouloskyriakos

~~When upgrading 14.46 will it be possible to upgrade seamlessly once there is a new ST android release or will I have to import a config backup/recreate the config to get rid of the database issues?~~ edit: was clarified that it'll be fixed automatically by @calmh in the forum.

Anyways it'd be really good if there was one last ST Android release 14.46X before @Nutomic quits as it'll take quiet some time to find someone as capable as him willing to take over the app development and to get everything setup.

generalmanager avatar Mar 13 '18 18:03 generalmanager