Fix crash on walker error (fixes #1507)
This commit is contained in:
parent
a7492f8612
commit
2e1e8f764e
@ -111,7 +111,8 @@ func (w *Walker) walkAndHashFiles(fchan chan protocol.FileInfo) filepath.WalkFun
|
|||||||
// Return value used when we are returning early and don't want to
|
// Return value used when we are returning early and don't want to
|
||||||
// process the item. For directories, this means do-not-descend.
|
// process the item. For directories, this means do-not-descend.
|
||||||
var skip error // nil
|
var skip error // nil
|
||||||
if info.IsDir() {
|
// info nil when error is not nil
|
||||||
|
if info != nil && info.IsDir() {
|
||||||
skip = filepath.SkipDir
|
skip = filepath.SkipDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -259,6 +259,14 @@ func TestNormalization(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssue1507(t *testing.T) {
|
||||||
|
w := Walker{}
|
||||||
|
c := make(chan protocol.FileInfo, 100)
|
||||||
|
fn := w.walkAndHashFiles(c)
|
||||||
|
|
||||||
|
fn("", nil, protocol.ErrClosed)
|
||||||
|
}
|
||||||
|
|
||||||
func walkDir(dir string) ([]protocol.FileInfo, error) {
|
func walkDir(dir string) ([]protocol.FileInfo, error) {
|
||||||
w := Walker{
|
w := Walker{
|
||||||
Dir: dir,
|
Dir: dir,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user