Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/osutil: IsDir returns true if path does not exist (fixes #3839) #3883

Closed

Conversation

AudriusButkevicius
Copy link
Member

The intent of the function is to verify that we are not traversing symlinks.
If the path along any component does not exist, we are not traversing anything, and it should be fine to let the updates through (as they are most likely only metadata updates)

/cc @Unrud

@calmh
Copy link
Member

calmh commented Jan 7, 2017

Note that this is a bugfix for the known cases when we are synchronizing a file in a directory that does not exist:

  • because the directory was deleted on one device, but the file updated on another
  • because the directory is ignored but the file inside it unignored

@calmh
Copy link
Member

calmh commented Jan 7, 2017

Should rename it if we do this check as the name is otherwise misleading.

@AudriusButkevicius
Copy link
Member Author

Yeah I had like 3 minutes before I had to leave the house. Probably should be TraversesSymlink

Copy link
Member

@calmh calmh left a comment

Choose a reason for hiding this comment

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

LGTM otherwise.

// base.
func IsDir(base, name string) bool {
path := base
info, err := Lstat(path)
if err != nil {
return false
return os.IsNotExist(err)
Copy link
Member

@calmh calmh Jan 8, 2017

Choose a reason for hiding this comment

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

I don't think we should change this return. If the base directory doesn't exist we're in deep water, probably "folder path missing" etc. This should not be the one causing issues today.

@@ -14,13 +14,14 @@ import (

// IsDir returns true if base and every path component of name up to and
// including filepath.Join(base, name) is a directory (and not a symlink or
// similar). Base and name must both be clean and name must be relative to
// similar), but returns true if the path is inaccessible,
Copy link
Member

Choose a reason for hiding this comment

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

This is broken. :) Maybe just ... is a directory or non-existent (and not a symlink?

@calmh
Copy link
Member

calmh commented Jan 8, 2017

@st-review lgtm

@st-review
Copy link

@calmh: Noted! Need another LGTM or explicit merge command.

@AudriusButkevicius
Copy link
Member Author

Merge this or the other implementation, whatever you prefer.

@calmh
Copy link
Member

calmh commented Jan 10, 2017

@st-review merge it!

@st-review
Copy link

👌 Merged as 1a1e35d. Thanks, @AudriusButkevicius!

@st-review st-review closed this Jan 10, 2017
st-review pushed a commit that referenced this pull request Jan 10, 2017
@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 Jan 10, 2018
@syncthing syncthing locked and limited conversation to collaborators Jan 10, 2018
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.

None yet

3 participants