From 99736e50666f481c27c762cca0f9f2b8621a24aa Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Thu, 13 Aug 2015 13:01:50 +0200 Subject: [PATCH] Ensure dir before files ordering when scanning --- lib/scanner/walk.go | 6 +++--- lib/scanner/walk_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/scanner/walk.go b/lib/scanner/walk.go index f14cf35b2..61dc88f9a 100644 --- a/lib/scanner/walk.go +++ b/lib/scanner/walk.go @@ -97,7 +97,7 @@ func (w *Walker) Walk() (chan protocol.FileInfo, error) { newParallelHasher(w.Dir, w.BlockSize, w.Hashers, hashedFiles, files) go func() { - hashFiles := w.walkAndHashFiles(files) + hashFiles := w.walkAndHashFiles(files, hashedFiles) if len(w.Subs) == 0 { filepath.Walk(w.Dir, hashFiles) } else { @@ -111,7 +111,7 @@ func (w *Walker) Walk() (chan protocol.FileInfo, error) { return hashedFiles, nil } -func (w *Walker) walkAndHashFiles(fchan chan protocol.FileInfo) filepath.WalkFunc { +func (w *Walker) walkAndHashFiles(fchan, dchan chan protocol.FileInfo) filepath.WalkFunc { now := time.Now() return func(p string, info os.FileInfo, err error) error { // Return value used when we are returning early and don't want to @@ -311,7 +311,7 @@ func (w *Walker) walkAndHashFiles(fchan chan protocol.FileInfo) filepath.WalkFun if debug { l.Debugln("dir:", p, f) } - fchan <- f + dchan <- f return nil } diff --git a/lib/scanner/walk_test.go b/lib/scanner/walk_test.go index 9d1368f9f..0d9bbcb66 100644 --- a/lib/scanner/walk_test.go +++ b/lib/scanner/walk_test.go @@ -274,7 +274,7 @@ func TestNormalization(t *testing.T) { func TestIssue1507(t *testing.T) { w := Walker{} c := make(chan protocol.FileInfo, 100) - fn := w.walkAndHashFiles(c) + fn := w.walkAndHashFiles(c, c) fn("", nil, protocol.ErrClosed) }