mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 19:08:58 +00:00
In the sequence of loading ignores, the error File Does Not Exist is not being considered a fatal error, since the .stignore file is allowed to not exist. However, included ignore files also tossed that same error in case those do not exist while in those cases it's considered an error and it should lead to the folder stopping. Changing the error when opening an included ignore file to something other than the regular does fix this issue, as in it now works again as described in the Documentation.
This commit is contained in:
parent
09efe03e1d
commit
9f131eee6b
@ -406,11 +406,19 @@ func loadParseIncludeFile(filesystem fs.Filesystem, file string, cd ChangeDetect
|
|||||||
}
|
}
|
||||||
|
|
||||||
if cd.Seen(filesystem, file) {
|
if cd.Seen(filesystem, file) {
|
||||||
return nil, parseError(fmt.Errorf("multiple include of ignore file %q", file))
|
return nil, errors.New("multiple include")
|
||||||
}
|
}
|
||||||
|
|
||||||
fd, info, err := loadIgnoreFile(filesystem, file)
|
fd, info, err := loadIgnoreFile(filesystem, file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// isNotExist is considered "ok" in a sense of that a folder doesn't have to act
|
||||||
|
// upon it. This is because it is allowed for .stignore to not exist. However,
|
||||||
|
// included ignore files are not allowed to be missing and these errors should be
|
||||||
|
// acted upon on. So we don't perserve the error chain here and manually set an
|
||||||
|
// error instead, if the file is missing.
|
||||||
|
if fs.IsNotExist(err) {
|
||||||
|
err = errors.New("file not found")
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer fd.Close()
|
defer fd.Close()
|
||||||
|
@ -197,6 +197,11 @@ func TestBadPatterns(t *testing.T) {
|
|||||||
if !IsParseError(err) {
|
if !IsParseError(err) {
|
||||||
t.Error("Should have been a parse error:", err)
|
t.Error("Should have been a parse error:", err)
|
||||||
}
|
}
|
||||||
|
if strings.HasPrefix(pat, "#include") {
|
||||||
|
if fs.IsNotExist(err) {
|
||||||
|
t.Error("Includes should not toss a regular isNotExist error")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user