Repository navigation
lib/fs: Don't add path separators at path ends (ref #5144) - #5146
Conversation
|
I don't think that's the right precaution. I think the right one is "paths on windows should never end in slash" and if we do that in rooted() we might not need to also do it in the fs constructor... |
|
@calmh Then I think we need to talk about all the path separator precautions in place, and which is really the desired behaviour. From the current implementation:
Now apparently the no trailing path separator on windows ever seems to be a valid concern. I do not see what's the reason for 3. - how do trailing path separators help penetrate symlinks? And why would that even be desired? Generally the "canonical" form of paths is Go is without a trailing path separator (which is also pretty usual in other places as far as I know). So unless there is a good reason for 3, I'd say we just go with no trailing path separator in the resulting paths (steps in between might still require it due to |
|
No 3 is desired on Unixes because it handles folder roots which are symlinks because foo/ will stat as directory when foo stats as symlink. Maybe that’s historical and not needed any more if we specifically allow the folder root to stat as symlink. If so we can probably simplify to always stripping trailing slashes.
|
|
😞 |
|
I had a frank discussion with Windows Defender and I think we managed to agree that the build agent artifacts are not to be considered threats henceforth. (Please don't abuse this trust :D) This LGTM - or rather, it looks like we're removing some safety checks, but the tests that verify them still pass so I'm OK with that. I think my new temporary test should just be folded into the list of paths that we already check in the other test you tweaked, last among the "windows special items" that already checked we handled the But that's a nit. 👍 from me |
|
Thanks for taking care of that devil (well generally taking care of that wind... stuff :) ). The removed safety checks were redundant since the introduction of I addressed the nit and rebased, as the original commits and commit messages aren't relevant anymore. |
* release: lib/model: Fixes on receive-only test setup and pulling (syncthing#5136) lib/fs: Don't add path separators at end of path (fixes syncthing#5144) (syncthing#5146) lib/fs: Evaluate root when watching not on fs creation (fixes syncthing#5043) (syncthing#5105)
Purpose
By @calmh in #5144
This treats the case specially when the path given to
rootedis equivalent to.(folder root), in that it just returnsBasicFilesystem.rootwithout modifying it, thus leaving the precautions taken innewBasicFilesystemuntouched.Testing
Needed to adjust and add some test cases to
TestRootedand added the test proposed by Jakob above.