scanner: Allow disabling weak hash in scanning (fixes #3891)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3905
This commit is contained in:
Audrius Butkevicius
2017-01-23 13:50:32 +00:00
committed by Jakob Borg
parent bd55ec79d2
commit dd78177ae0
10 changed files with 45 additions and 22 deletions

View File

@@ -72,6 +72,8 @@ type Config struct {
ProgressTickIntervalS int
// Signals cancel from the outside - when closed, we should stop walking.
Cancel chan struct{}
// Wether or not we should also compute weak hashes
UseWeakHashes bool
}
type CurrentFiler interface {
@@ -129,7 +131,7 @@ func (w *walker) walk() (chan protocol.FileInfo, error) {
// We're not required to emit scan progress events, just kick off hashers,
// and feed inputs directly from the walker.
if w.ProgressTickIntervalS < 0 {
newParallelHasher(w.Dir, w.BlockSize, w.Hashers, finishedChan, toHashChan, nil, nil, w.Cancel)
newParallelHasher(w.Dir, w.BlockSize, w.Hashers, finishedChan, toHashChan, nil, nil, w.Cancel, w.UseWeakHashes)
return finishedChan, nil
}
@@ -160,7 +162,7 @@ func (w *walker) walk() (chan protocol.FileInfo, error) {
done := make(chan struct{})
progress := newByteCounter()
newParallelHasher(w.Dir, w.BlockSize, w.Hashers, finishedChan, realToHashChan, progress, done, w.Cancel)
newParallelHasher(w.Dir, w.BlockSize, w.Hashers, finishedChan, realToHashChan, progress, done, w.Cancel, w.UseWeakHashes)
// A routine which actually emits the FolderScanProgress events
// every w.ProgressTicker ticks, until the hasher routines terminate.