Fast parallel file hasher (fixes #293)

This commit is contained in:
Jakob Borg
2014-07-30 20:10:46 +02:00
parent c47aebdd2a
commit 2be1218aa3
3 changed files with 91 additions and 32 deletions

View File

@@ -7,6 +7,7 @@ package scanner
import (
"fmt"
"reflect"
"sort"
"testing"
"time"
@@ -39,6 +40,7 @@ func TestWalk(t *testing.T) {
for f := range fchan {
files = append(files, f)
}
sort.Sort(fileList(files))
if err != nil {
t.Fatal(err)
@@ -133,3 +135,17 @@ func TestIgnore(t *testing.T) {
}
}
}
type fileList []protocol.FileInfo
func (f fileList) Len() int {
return len(f)
}
func (f fileList) Less(a, b int) bool {
return f[a].Name < f[b].Name
}
func (f fileList) Swap(a, b int) {
f[a], f[b] = f[b], f[a]
}