mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 14:50:56 +00:00
Ensure dir before files ordering when scanning
This commit is contained in:
parent
681306b7a1
commit
99736e5066
@ -97,7 +97,7 @@ func (w *Walker) Walk() (chan protocol.FileInfo, error) {
|
|||||||
newParallelHasher(w.Dir, w.BlockSize, w.Hashers, hashedFiles, files)
|
newParallelHasher(w.Dir, w.BlockSize, w.Hashers, hashedFiles, files)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
hashFiles := w.walkAndHashFiles(files)
|
hashFiles := w.walkAndHashFiles(files, hashedFiles)
|
||||||
if len(w.Subs) == 0 {
|
if len(w.Subs) == 0 {
|
||||||
filepath.Walk(w.Dir, hashFiles)
|
filepath.Walk(w.Dir, hashFiles)
|
||||||
} else {
|
} else {
|
||||||
@ -111,7 +111,7 @@ func (w *Walker) Walk() (chan protocol.FileInfo, error) {
|
|||||||
return hashedFiles, nil
|
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()
|
now := time.Now()
|
||||||
return func(p string, info os.FileInfo, err error) error {
|
return func(p string, info os.FileInfo, err error) error {
|
||||||
// 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
|
||||||
@ -311,7 +311,7 @@ func (w *Walker) walkAndHashFiles(fchan chan protocol.FileInfo) filepath.WalkFun
|
|||||||
if debug {
|
if debug {
|
||||||
l.Debugln("dir:", p, f)
|
l.Debugln("dir:", p, f)
|
||||||
}
|
}
|
||||||
fchan <- f
|
dchan <- f
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ func TestNormalization(t *testing.T) {
|
|||||||
func TestIssue1507(t *testing.T) {
|
func TestIssue1507(t *testing.T) {
|
||||||
w := Walker{}
|
w := Walker{}
|
||||||
c := make(chan protocol.FileInfo, 100)
|
c := make(chan protocol.FileInfo, 100)
|
||||||
fn := w.walkAndHashFiles(c)
|
fn := w.walkAndHashFiles(c, c)
|
||||||
|
|
||||||
fn("", nil, protocol.ErrClosed)
|
fn("", nil, protocol.ErrClosed)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user