Skip to content

lib/fs: Evaluate root when watching not on fs creation (fixes #5043) - #5105

Merged
calmh merged 6 commits into
syncthing:masterfrom
imsodin:watchSymlink
Aug 11, 2018
Merged

calmh merged 6 commits into
syncthing:masterfrom
imsodin:watchSymlink

Conversation

@imsodin

@imsodin imsodin commented Aug 8, 2018

Copy link
Copy Markdown
Member

Purpose

Currently the folder root is evaluated (to resolve symlinks) at fs creation. At that point the directory may not exist or EvalSymlinks may fail for other reasons. The current implementation just ignores that case by assuming there are no symlinks. That's dangerous because if there are, it will lead to panics on watching. Also the only place where this evaluated root is needed is for watching. Therefore the evaluation of the root path now happens when fs.Watch is called. This call will then just fail if filepath.EvalSymlinks returns an error, making it transparent to the user, leading to retries and preventing the panic.

Testing

Existing ones still pass.

calmh
calmh previously approved these changes Aug 11, 2018

@calmh calmh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

Comment thread lib/fs/basicfs.go Outdated
// penetrate symlinks. On Windows, paths must not end with a slash.
if root[len(root)-1] != filepath.Separator {
root = longFilenameSupport(root)
} else if root[len(root)-1] != filepath.Separator {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd do a real strings.HasSuffix here instead, avoids crashing on the empty string etc

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I also adapted the windows fs creation test for unixes to check this and other basic scenarios. Apparently the tilde and absolutification meddling above already changed "" to "/", so it wouldn't panic even before.

@calmh

calmh commented Aug 11, 2018 •

Copy link
Copy Markdown
Member
folder_recvonly_test.go:206: mkdir _recvonly: Access is denied.

I've seen that permission denied error before, but I don't remember what caused it. IIRC, somehow the "_recvonly" dir or the containing dir gets chmod 000 due to some integration with another test... It passes reliably in master and fails reliably on this branch which is odd.

@imsodin

imsodin commented Aug 11, 2018

Copy link
Copy Markdown
Member Author

It does not pass reliable on master, it just seems to be happening a whole lot right now. See e.g. here: https://build.syncthing.net/viewLog.html?buildId=24835&tab=buildResultsDiv&buildTypeId=Syncthing_BuildWindows#testNameId8662697608653222476

I initially didn't want to fix #5110 immediately (that's why I created the issue as a reminder), but these recurrent failures changed my mind - PR incoming. Hopefully it will actually fix things...

imsodin added a commit to imsodin/syncthing that referenced this pull request Aug 11, 2018
@calmh
calmh merged commit e20679a into syncthing:master Aug 11, 2018
@imsodin
imsodin deleted the watchSymlink branch August 12, 2018 01:37
@calmh calmh added this to the v0.14.51 milestone Aug 15, 2018
calmh added a commit to calmh/syncthing that referenced this pull request Sep 2, 2018
* 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)
@calmh calmh modified the milestones: v0.14.51, v0.14.50 Sep 2, 2018
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Aug 12, 2019
@syncthing syncthing locked and limited conversation to collaborators Aug 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants