Commit 655acb4c authored by Jakob Borg's avatar Jakob Borg

Deprecate scanner.Block & File

parent 91b35118
......@@ -96,7 +96,7 @@ setup() {
}
xdr() {
for f in discover/packets files/leveldb protocol/message scanner/blocks scanner/file ; do
for f in discover/packets files/leveldb protocol/message ; do
go run xdr/cmd/genxdr/main.go -- "${f}.go" > "${f}_xdr.go"
done
}
......
......@@ -18,7 +18,6 @@ import (
"code.google.com/p/go.crypto/bcrypt"
"github.com/calmh/syncthing/logger"
"github.com/calmh/syncthing/protocol"
"github.com/calmh/syncthing/scanner"
)
var l = logger.DefaultLogger
......@@ -122,11 +121,11 @@ func (r *RepositoryConfiguration) NodeIDs() []protocol.NodeID {
return r.nodeIDs
}
func (r RepositoryConfiguration) FileRanker() func(scanner.File) int {
func (r RepositoryConfiguration) FileRanker() func(protocol.FileInfo) int {
if len(r.SyncOrderPatterns) <= 0 {
return nil
}
return func(f scanner.File) int {
return func(f protocol.FileInfo) int {
ret := 0
for _, v := range r.SyncOrderPatterns {
if v.CompiledPattern().MatchString(f.Name) {
......
......@@ -13,7 +13,6 @@ import (
"github.com/calmh/syncthing/files"
"github.com/calmh/syncthing/protocol"
"github.com/calmh/syncthing/scanner"
)
var node1, node2, node3, node4 protocol.NodeID
......@@ -274,7 +273,7 @@ func TestFileSorter(t *testing.T) {
},
}
f := []scanner.File{
f := []protocol.FileInfo{
{Name: "bar.mov"},
{Name: "baz.txt"},
{Name: "foo.jpg"},
......@@ -290,7 +289,7 @@ func TestFileSorter(t *testing.T) {
files.SortBy(rcfg.FileRanker()).Sort(f)
expected := []scanner.File{
expected := []protocol.FileInfo{
{Name: "camera-uploads/foo.jpg"},
{Name: "camera-uploads/herp.mov"},
{Name: "camera-uploads/hurr.pl"},
......@@ -314,7 +313,7 @@ func TestFileSorter(t *testing.T) {
}
}
func formatFiles(f []scanner.File) string {
func formatFiles(f []protocol.FileInfo) string {
ret := ""
for _, v := range f {
......
......@@ -8,7 +8,6 @@ import (
"github.com/calmh/syncthing/files"
"github.com/calmh/syncthing/protocol"
"github.com/calmh/syncthing/scanner"
"github.com/syndtr/goleveldb/leveldb"
)
......@@ -29,7 +28,7 @@ func main() {
if *node == "" {
log.Printf("*** Global index for repo %q", *repo)
fs.WithGlobal(func(f scanner.File) bool {
fs.WithGlobal(func(f protocol.FileInfo) bool {
fmt.Println(f)
fmt.Println("\t", fs.Availability(f.Name))
return true
......@@ -40,7 +39,7 @@ func main() {
log.Fatal(err)
}
log.Printf("*** Have index for repo %q node %q", *repo, n)
fs.WithHave(n, func(f scanner.File) bool {
fs.WithHave(n, func(f protocol.FileInfo) bool {
fmt.Println(f)
return true
})
......
......@@ -6,7 +6,6 @@ import (
"github.com/calmh/syncthing/lamport"
"github.com/calmh/syncthing/protocol"
"github.com/calmh/syncthing/scanner"
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/iterator"
"github.com/syndtr/goleveldb/leveldb/opt"
......@@ -27,7 +26,7 @@ type versionList struct {
versions []fileVersion
}
type fileList []scanner.File
type fileList []protocol.FileInfo
func (l fileList) Len() int {
return len(l)
......@@ -94,9 +93,9 @@ func globalKeyName(key []byte) []byte {
type deletionHandler func(db dbReader, batch dbWriter, repo, node, name []byte, dbi iterator.Iterator) bool
type fileIterator func(f scanner.File) bool
type fileIterator func(f protocol.FileInfo) bool
func ldbGenericReplace(db *leveldb.DB, repo, node []byte, fs []scanner.File, deleteFn deletionHandler) bool {
func ldbGenericReplace(db *leveldb.DB, repo, node []byte, fs []protocol.FileInfo, deleteFn deletionHandler) bool {
sort.Sort(fileList(fs)) // sort list on name, same as on disk
start := nodeKey(repo, node, nil) // before all repo/node files
......@@ -153,7 +152,7 @@ func ldbGenericReplace(db *leveldb.DB, repo, node []byte, fs []scanner.File, del
case cmp == 0:
// File exists on both sides - compare versions.
var ef scanner.File
var ef protocol.FileInfo
ef.UnmarshalXDR(dbi.Value())
if fs[fsi].Version > ef.Version {
ldbInsert(batch, repo, node, newName, fs[fsi])
......@@ -182,7 +181,7 @@ func ldbGenericReplace(db *leveldb.DB, repo, node []byte, fs []scanner.File, del
return changed
}
func ldbReplace(db *leveldb.DB, repo, node []byte, fs []scanner.File) bool {
func ldbReplace(db *leveldb.DB, repo, node []byte, fs []protocol.FileInfo) bool {
return ldbGenericReplace(db, repo, node, fs, func(db dbReader, batch dbWriter, repo, node, name []byte, dbi iterator.Iterator) bool {
// Disk has files that we are missing. Remove it.
if debug {
......@@ -194,9 +193,9 @@ func ldbReplace(db *leveldb.DB, repo, node []byte, fs []scanner.File) bool {
})
}
func ldbReplaceWithDelete(db *leveldb.DB, repo, node []byte, fs []scanner.File) bool {
func ldbReplaceWithDelete(db *leveldb.DB, repo, node []byte, fs []protocol.FileInfo) bool {
return ldbGenericReplace(db, repo, node, fs, func(db dbReader, batch dbWriter, repo, node, name []byte, dbi iterator.Iterator) bool {
var f scanner.File
var f protocol.FileInfo
err := f.UnmarshalXDR(dbi.Value())
if err != nil {
panic(err)
......@@ -216,7 +215,7 @@ func ldbReplaceWithDelete(db *leveldb.DB, repo, node []byte, fs []scanner.File)
})
}
func ldbUpdate(db *leveldb.DB, repo, node []byte, fs []scanner.File) bool {
func ldbUpdate(db *leveldb.DB, repo, node []byte, fs []protocol.FileInfo) bool {
batch := new(leveldb.Batch)
snap, err := db.GetSnapshot()
if err != nil {
......@@ -234,7 +233,7 @@ func ldbUpdate(db *leveldb.DB, repo, node []byte, fs []scanner.File) bool {
continue
}
var ef scanner.File
var ef protocol.FileInfo
err = ef.UnmarshalXDR(bs)
if err != nil {
panic(err)
......@@ -253,7 +252,7 @@ func ldbUpdate(db *leveldb.DB, repo, node []byte, fs []scanner.File) bool {
return true
}
func ldbInsert(batch dbWriter, repo, node, name []byte, file scanner.File) {
func ldbInsert(batch dbWriter, repo, node, name []byte, file protocol.FileInfo) {
if debug {
l.Debugf("insert; repo=%q node=%x %v", repo, node, file)
}
......@@ -362,7 +361,7 @@ func ldbWithHave(db *leveldb.DB, repo, node []byte, fn fileIterator) {
defer dbi.Release()
for dbi.Next() {
var f scanner.File
var f protocol.FileInfo
err := f.UnmarshalXDR(dbi.Value())
if err != nil {
panic(err)
......@@ -373,17 +372,17 @@ func ldbWithHave(db *leveldb.DB, repo, node []byte, fn fileIterator) {
}
}
func ldbGet(db *leveldb.DB, repo, node, file []byte) scanner.File {
func ldbGet(db *leveldb.DB, repo, node, file []byte) protocol.FileInfo {
nk := nodeKey(repo, node, file)
bs, err := db.Get(nk, nil)
if err == leveldb.ErrNotFound {
return scanner.File{}
return protocol.FileInfo{}
}
if err != nil {
panic(err)
}
var f scanner.File
var f protocol.FileInfo
err = f.UnmarshalXDR(bs)
if err != nil {
panic(err)
......@@ -391,7 +390,7 @@ func ldbGet(db *leveldb.DB, repo, node, file []byte) scanner.File {
return f
}
func ldbGetGlobal(db *leveldb.DB, repo, file []byte) scanner.File {
func ldbGetGlobal(db *leveldb.DB, repo, file []byte) protocol.FileInfo {
k := globalKey(repo, file)
snap, err := db.GetSnapshot()
if err != nil {
......@@ -401,7 +400,7 @@ func ldbGetGlobal(db *leveldb.DB, repo, file []byte) scanner.File {
bs, err := snap.Get(k, nil)
if err == leveldb.ErrNotFound {
return scanner.File{}
return protocol.FileInfo{}
}
if err != nil {
panic(err)
......@@ -423,7 +422,7 @@ func ldbGetGlobal(db *leveldb.DB, repo, file []byte) scanner.File {
panic(err)
}
var f scanner.File
var f protocol.FileInfo
err = f.UnmarshalXDR(bs)
if err != nil {
panic(err)
......@@ -458,7 +457,7 @@ func ldbWithGlobal(db *leveldb.DB, repo []byte, fn fileIterator) {
panic(err)
}
var f scanner.File
var f protocol.FileInfo
err = f.UnmarshalXDR(bs)
if err != nil {
panic(err)
......@@ -544,7 +543,7 @@ func ldbWithNeed(db *leveldb.DB, repo, node []byte, fn fileIterator) {
panic(err)
}
var gf scanner.File
var gf protocol.FileInfo
err = gf.UnmarshalXDR(bs)
if err != nil {
panic(err)
......
......@@ -9,12 +9,11 @@ import (
"sync"
"github.com/calmh/syncthing/protocol"
"github.com/calmh/syncthing/scanner"
"github.com/syndtr/goleveldb/leveldb"
)
type fileRecord struct {
File scanner.File
File protocol.FileInfo
Usage int
Global bool
}
......@@ -37,7 +36,7 @@ func NewSet(repo string, db *leveldb.DB) *Set {
return &s
}
func (s *Set) Replace(node protocol.NodeID, fs []scanner.File) {
func (s *Set) Replace(node protocol.NodeID, fs []protocol.FileInfo) {
if debug {
l.Debugf("%s Replace(%v, [%d])", s.repo, node, len(fs))
}
......@@ -48,7 +47,7 @@ func (s *Set) Replace(node protocol.NodeID, fs []scanner.File) {
}
}
func (s *Set) ReplaceWithDelete(node protocol.NodeID, fs []scanner.File) {
func (s *Set) ReplaceWithDelete(node protocol.NodeID, fs []protocol.FileInfo) {
if debug {
l.Debugf("%s ReplaceWithDelete(%v, [%d])", s.repo, node, len(fs))
}
......@@ -59,7 +58,7 @@ func (s *Set) ReplaceWithDelete(node protocol.NodeID, fs []scanner.File) {
}
}
func (s *Set) Update(node protocol.NodeID, fs []scanner.File) {
func (s *Set) Update(node protocol.NodeID, fs []protocol.FileInfo) {
if debug {
l.Debugf("%s Update(%v, [%d])", s.repo, node, len(fs))
}
......@@ -91,11 +90,11 @@ func (s *Set) WithGlobal(fn fileIterator) {
ldbWithGlobal(s.db, []byte(s.repo), fn)
}
func (s *Set) Get(node protocol.NodeID, file string) scanner.File {
func (s *Set) Get(node protocol.NodeID, file string) protocol.FileInfo {
return ldbGet(s.db, []byte(s.repo), node[:], []byte(file))
}
func (s *Set) GetGlobal(file string) scanner.File {
func (s *Set) GetGlobal(file string) protocol.FileInfo {
return ldbGetGlobal(s.db, []byte(s.repo), []byte(file))
}
......
This diff is collapsed.
......@@ -2,13 +2,12 @@ package files
import (
"sort"
"github.com/calmh/syncthing/scanner"
"github.com/calmh/syncthing/protocol"
)
type SortBy func(p scanner.File) int
type SortBy func(p protocol.FileInfo) int
func (by SortBy) Sort(files []scanner.File) {
func (by SortBy) Sort(files []protocol.FileInfo) {
ps := &fileSorter{
files: files,
by: by,
......@@ -17,8 +16,8 @@ func (by SortBy) Sort(files []scanner.File) {
}
type fileSorter struct {
files []scanner.File
by func(p1 scanner.File) int
files []protocol.FileInfo
by func(p1 protocol.FileInfo) int
}
func (s *fileSorter) Len() int {
......
......@@ -7,19 +7,19 @@ package model
import (
"sync"
"github.com/calmh/syncthing/scanner"
"github.com/calmh/syncthing/protocol"
)
type bqAdd struct {
file scanner.File
have []scanner.Block
need []scanner.Block
file protocol.FileInfo
have []protocol.BlockInfo
need []protocol.BlockInfo
}
type bqBlock struct {
file scanner.File
block scanner.Block // get this block from the network
copy []scanner.Block // copy these blocks from the old version of the file
file protocol.FileInfo
block protocol.BlockInfo // get this block from the network
copy []protocol.BlockInfo // copy these blocks from the old version of the file
first bool
last bool
}
......
......@@ -162,11 +162,13 @@ func (m *Model) ConnectionStats() map[string]ConnectionInfo {
var have int64
for _, repo := range m.nodeRepos[node] {
m.repoFiles[repo].WithGlobal(func(f scanner.File) bool {
m.repoFiles[repo].WithGlobal(func(f protocol.FileInfo) bool {
if !protocol.IsDeleted(f.Flags) {
size := f.Size
var size int64
if protocol.IsDirectory(f.Flags) {
size = zeroEntrySize
} else {
size = f.Size()
}
tot += size
have += size
......@@ -174,11 +176,13 @@ func (m *Model) ConnectionStats() map[string]ConnectionInfo {
return true
})
m.repoFiles[repo].WithNeed(node, func(f scanner.File) bool {
m.repoFiles[repo].WithNeed(node, func(f protocol.FileInfo) bool {
if !protocol.IsDeleted(f.Flags) {
size := f.Size
var size int64
if protocol.IsDirectory(f.Flags) {
size = zeroEntrySize
} else {
size = f.Size()
}
have -= size
}
......@@ -209,7 +213,7 @@ func (m *Model) ConnectionStats() map[string]ConnectionInfo {
return res
}
func sizeOf(fs []scanner.File) (files, deleted int, bytes int64) {
func sizeOf(fs []protocol.FileInfo) (files, deleted int, bytes int64) {
for _, f := range fs {
fs, de, by := sizeOfFile(f)
files += fs
......@@ -219,11 +223,11 @@ func sizeOf(fs []scanner.File) (files, deleted int, bytes int64) {
return
}
func sizeOfFile(f scanner.File) (files, deleted int, bytes int64) {
func sizeOfFile(f protocol.FileInfo) (files, deleted int, bytes int64) {
if !protocol.IsDeleted(f.Flags) {
files++
if !protocol.IsDirectory(f.Flags) {
bytes += f.Size
bytes += f.Size()
} else {
bytes += zeroEntrySize
}
......@@ -240,7 +244,7 @@ func (m *Model) GlobalSize(repo string) (files, deleted int, bytes int64) {
m.rmut.RLock()
defer m.rmut.RUnlock()
if rf, ok := m.repoFiles[repo]; ok {
rf.WithGlobal(func(f scanner.File) bool {
rf.WithGlobal(func(f protocol.FileInfo) bool {
fs, de, by := sizeOfFile(f)
files += fs
deleted += de
......@@ -257,7 +261,7 @@ func (m *Model) LocalSize(repo string) (files, deleted int, bytes int64) {
m.rmut.RLock()
defer m.rmut.RUnlock()
if rf, ok := m.repoFiles[repo]; ok {
rf.WithHave(protocol.LocalNodeID, func(f scanner.File) bool {
rf.WithHave(protocol.LocalNodeID, func(f protocol.FileInfo) bool {
fs, de, by := sizeOfFile(f)
files += fs
deleted += de
......@@ -275,12 +279,12 @@ func (m *Model) NeedSize(repo string) (files int, bytes int64) {
}
// NeedFiles returns the list of currently needed files
func (m *Model) NeedFilesRepo(repo string) []scanner.File {
func (m *Model) NeedFilesRepo(repo string) []protocol.FileInfo {
m.rmut.RLock()
defer m.rmut.RUnlock()
if rf, ok := m.repoFiles[repo]; ok {
var fs []scanner.File
rf.WithNeed(protocol.LocalNodeID, func(f scanner.File) bool {
var fs []protocol.FileInfo
rf.WithNeed(protocol.LocalNodeID, func(f protocol.FileInfo) bool {
fs = append(fs, f)
return true
})
......@@ -304,23 +308,9 @@ func (m *Model) Index(nodeID protocol.NodeID, repo string, fs []protocol.FileInf
return
}
var files = make([]scanner.File, len(fs))
for i := range fs {
f := fs[i]
lamport.Default.Tick(f.Version)
if debug {
var flagComment string
if protocol.IsDeleted(f.Flags) {
flagComment = " (deleted)"
}
l.Debugf("IDX(in): %s %q/%q m=%d f=%o%s v=%d (%d blocks)", nodeID, repo, f.Name, f.Modified, f.Flags, flagComment, f.Version, len(f.Blocks))
}
files[i] = fileFromFileInfo(f)
}
m.rmut.RLock()
if r, ok := m.repoFiles[repo]; ok {
r.Replace(nodeID, files)
r.Replace(nodeID, fs)
} else {
l.Fatalf("Index for nonexistant repo %q", repo)
}
......@@ -339,23 +329,9 @@ func (m *Model) IndexUpdate(nodeID protocol.NodeID, repo string, fs []protocol.F
return
}
var files = make([]scanner.File, len(fs))
for i := range fs {
f := fs[i]
lamport.Default.Tick(f.Version)
if debug {
var flagComment string
if protocol.IsDeleted(f.Flags) {
flagComment = " (deleted)"
}
l.Debugf("IDXUP(in): %s %q/%q m=%d f=%o%s v=%d (%d blocks)", nodeID, repo, f.Name, f.Modified, f.Flags, flagComment, f.Version, len(f.Blocks))
}
files[i] = fileFromFileInfo(f)
}
m.rmut.RLock()
if r, ok := m.repoFiles[repo]; ok {
r.Update(nodeID, files)
r.Update(nodeID, fs)
} else {
l.Fatalf("IndexUpdate for nonexistant repo %q", repo)
}
......@@ -432,14 +408,14 @@ func (m *Model) Request(nodeID protocol.NodeID, repo, name string, offset int64,
}
lf := r.Get(protocol.LocalNodeID, name)
if lf.Suppressed || protocol.IsDeleted(lf.Flags) {
if protocol.IsInvalid(lf.Flags) || protocol.IsDeleted(lf.Flags) {
if debug {
l.Debugf("REQ(in): %s: %q / %q o=%d s=%d; invalid: %v", nodeID, repo, name, offset, size, lf)
}
return nil, ErrInvalid
}
if offset > lf.Size {
if offset > lf.Size() {
if debug {
l.Debugf("REQ(in; nonexistent): %s: %q o=%d s=%d", nodeID, name, offset, size)
}
......@@ -468,20 +444,20 @@ func (m *Model) Request(nodeID protocol.NodeID, repo, name string, offset int64,
}
// ReplaceLocal replaces the local repository index with the given list of files.
func (m *Model) ReplaceLocal(repo string, fs []scanner.File) {
func (m *Model) ReplaceLocal(repo string, fs []protocol.FileInfo) {
m.rmut.RLock()
m.repoFiles[repo].ReplaceWithDelete(protocol.LocalNodeID, fs)
m.rmut.RUnlock()
}
func (m *Model) CurrentRepoFile(repo string, file string) scanner.File {
func (m *Model) CurrentRepoFile(repo string, file string) protocol.FileInfo {
m.rmut.RLock()
f := m.repoFiles[repo].Get(protocol.LocalNodeID, file)
m.rmut.RUnlock()
return f
}
func (m *Model) CurrentGlobalFile(repo string, file string) scanner.File {
func (m *Model) CurrentGlobalFile(repo string, file string) protocol.FileInfo {
m.rmut.RLock()
f := m.repoFiles[repo].GetGlobal(file)
m.rmut.RUnlock()
......@@ -494,7 +470,7 @@ type cFiler struct {
}
// Implements scanner.CurrentFiler
func (cf cFiler) CurrentFile(file string) scanner.File {
func (cf cFiler) CurrentFile(file string) protocol.FileInfo {
return cf.m.CurrentRepoFile(cf.r, file)
}
......@@ -552,32 +528,18 @@ func (m *Model) AddConnection(rawConn io.Closer, protoConn protocol.Connection)
// protocolIndex returns the current local index in protocol data types.
func (m *Model) protocolIndex(repo string) []protocol.FileInfo {
var index []protocol.FileInfo
var fs []scanner.File
m.repoFiles[repo].WithHave(protocol.LocalNodeID, func(f scanner.File) bool {
var fs []protocol.FileInfo
m.repoFiles[repo].WithHave(protocol.LocalNodeID, func(f protocol.FileInfo) bool {
fs = append(fs, f)
return true
})
for _, f := range fs {
mf := fileInfoFromFile(f)
if debug {
var flagComment string
if protocol.IsDeleted(mf.Flags) {
flagComment = " (deleted)"
}
l.Debugf("IDX(out): %q/%q m=%d f=%o%s v=%d (%d blocks)", repo, mf.Name, mf.Modified, mf.Flags, flagComment, mf.Version, len(mf.Blocks))
}
index = append(index, mf)
}
return index
return fs
}
func (m *Model) updateLocal(repo string, f scanner.File) {
func (m *Model) updateLocal(repo string, f protocol.FileInfo) {
m.rmut.RLock()
m.repoFiles[repo].Update(protocol.LocalNodeID, []scanner.File{f})
m.repoFiles[repo].Update(protocol.LocalNodeID, []protocol.FileInfo{f})
m.rmut.RUnlock()
}
......@@ -736,11 +698,10 @@ func (m *Model) LoadIndexes(dir string) {
for repo := range m.repoCfgs {
fs := m.loadIndex(repo, dir)
var sfs = make([]scanner.File, len(fs))
var sfs = make([]protocol.FileInfo, len(fs))
for i := 0; i < len(fs); i++ {
lamport.Default.Tick(fs[i].Version)
sfs[i] = fileFromFileInfo(fs[i])
sfs[i].Suppressed = false // we might have saved an index with files that were suppressed; the should not be on startup
fs[i].Flags &= ^uint32(protocol.FlagInvalid) // we might have saved an index with files that were suppressed; the should not be on startup
}
m.repoFiles[repo].Replace(protocol.LocalNodeID, sfs)
......
......@@ -13,7 +13,6 @@ import (
"github.com/calmh/syncthing/config"
"github.com/calmh/syncthing/protocol"
"github.com/calmh/syncthing/scanner"
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/storage"
)
......@@ -25,27 +24,24 @@ func init() {
node2, _ = protocol.NodeIDFromString("GYRZZQB-IRNPV4Z-T7TC52W-EQYJ3TT-FDQW6MW-DFLMU42-SSSU6EM-FBK2VAY")
}
var testDataExpected = map[string]scanner.File{
"foo": scanner.File{
var testDataExpected = map[string]protocol.FileInfo{
"foo": protocol.FileInfo{
Name: "foo",
Flags: 0,
Modified: 0,
Size: 7,
Blocks: []scanner.Block{{Offset: 0x0, Size: 0x7, Hash: []uint8{0xae, 0xc0, 0x70, 0x64, 0x5f, 0xe5, 0x3e, 0xe3, 0xb3, 0x76, 0x30, 0x59, 0x37, 0x61, 0x34, 0xf0, 0x58, 0xcc, 0x33, 0x72, 0x47, 0xc9, 0x78, 0xad, 0xd1, 0x78, 0xb6, 0xcc, 0xdf, 0xb0, 0x1, 0x9f}}},
Blocks: []protocol.BlockInfo{{Offset: 0x0, Size: 0x7, Hash: []uint8{0xae, 0xc0, 0x70, 0x64, 0x5f, 0xe5, 0x3e, 0xe3, 0xb3, 0x76, 0x30, 0x59, 0x37, 0x61, 0x34, 0xf0, 0x58, 0xcc, 0x33, 0x72, 0x47, 0xc9, 0x78, 0xad, 0xd1, 0x78, 0xb6, 0xcc, 0xdf, 0xb0, 0x1, 0x9f}}},
},
"empty": scanner.File{
"empty": protocol.FileInfo{
Name: "empty",
Flags: 0,
Modified: 0,
Size: 0,
Blocks: []scanner.Block{{Offset: 0x0, Size: 0x0, Hash: []uint8{0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55}}},
Blocks: []protocol.BlockInfo{{Offset: 0x0, Size: 0x0, Hash: []uint8{0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55}}},
},
"bar": scanner.File{
"bar": protocol.FileInfo{
Name: "bar",
Flags: 0,
Modified: 0,
Size: 10,
Blocks: []scanner.Block{{Offset: 0x0, Size: 0xa, Hash: []uint8{0x2f, 0x72, 0xcc, 0x11, 0xa6, 0xfc, 0xd0, 0x27, 0x1e, 0xce, 0xf8, 0xc6, 0x10, 0x56, 0xee, 0x1e, 0xb1, 0x24, 0x3b, 0xe3, 0x80, 0x5b, 0xf9, 0xa9, 0xdf, 0x98, 0xf9, 0x2f, 0x76, 0x36, 0xb0, 0x5c}}},
Blocks: []protocol.BlockInfo{{Offset: 0x0, Size: 0xa, Hash: []uint8{0x2f, 0x72, 0xcc, 0x11, 0xa6, 0xfc, 0xd0, 0x27, 0x1e, 0xce, 0xf8, 0xc6, 0x10, 0x56, 0xee, 0x1e, 0xb1, 0x24, 0x3b, 0xe3, 0x80, 0x5b, 0xf9, 0xa9, 0xdf, 0x98, 0xf9, 0x2f, 0x76, 0x36, 0xb0, 0x5c}}},
},
}
......@@ -89,7 +85,7 @@ func genFiles(n int) []protocol.FileInfo {