mirror of
https://github.com/syncthing/syncthing.git
synced 2024-11-15 09:58:57 -07:00
Cleanup SeedIndex
This commit is contained in:
parent
24efbe7d33
commit
469e96126a
31
model.go
31
model.go
@ -149,21 +149,7 @@ func (m *Model) SeedIndex(fs []protocol.FileInfo) {
|
||||
|
||||
m.local = make(map[string]File)
|
||||
for _, f := range fs {
|
||||
mf := File{
|
||||
Name: f.Name,
|
||||
Flags: f.Flags,
|
||||
Modified: int64(f.Modified),
|
||||
}
|
||||
var offset uint64
|
||||
for _, b := range f.Blocks {
|
||||
mf.Blocks = append(mf.Blocks, Block{
|
||||
Offset: offset,
|
||||
Length: b.Length,
|
||||
Hash: b.Hash,
|
||||
})
|
||||
offset += uint64(b.Length)
|
||||
}
|
||||
m.local[f.Name] = mf
|
||||
m.local[f.Name] = fileFromProtocol(f)
|
||||
}
|
||||
|
||||
m.recomputeGlobal()
|
||||
@ -451,19 +437,20 @@ func (m *Model) AddNode(node *protocol.Connection) {
|
||||
}
|
||||
|
||||
func fileFromProtocol(f protocol.FileInfo) File {
|
||||
mf := File{
|
||||
Name: f.Name,
|
||||
Flags: f.Flags,
|
||||
Modified: int64(f.Modified),
|
||||
}
|
||||
var blocks []Block
|
||||
var offset uint64
|
||||
for _, b := range f.Blocks {
|
||||
mf.Blocks = append(mf.Blocks, Block{
|
||||
blocks = append(blocks, Block{
|
||||
Offset: offset,
|
||||
Length: b.Length,
|
||||
Hash: b.Hash,
|
||||
})
|
||||
offset += uint64(b.Length)
|
||||
}
|
||||
return mf
|
||||
return File{
|
||||
Name: f.Name,
|
||||
Flags: f.Flags,
|
||||
Modified: int64(f.Modified),
|
||||
Blocks: blocks,
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user