all: Move remaining protos to use the vanity plugin (#7009)

This commit is contained in:
Audrius Butkevicius
2020-10-02 08:07:05 +02:00
committed by GitHub
parent 7774932302
commit e027175446
55 changed files with 8353 additions and 1396 deletions
+5 -5
View File
@@ -16,7 +16,7 @@ import (
// FileInfo.Blocks that the remote device already has, and version represents
// the version of the file that the remote device is downloading.
type deviceFolderFileDownloadState struct {
blockIndexes []int32
blockIndexes []int
version protocol.Vector
blockSize int
}
@@ -30,7 +30,7 @@ type deviceFolderDownloadState struct {
// Has returns whether a block at that specific index, and that specific version of the file
// is currently available on the remote device for pulling from a temporary file.
func (p *deviceFolderDownloadState) Has(file string, version protocol.Vector, index int32) bool {
func (p *deviceFolderDownloadState) Has(file string, version protocol.Vector, index int) bool {
p.mut.RLock()
defer p.mut.RUnlock()
@@ -56,9 +56,9 @@ func (p *deviceFolderDownloadState) Update(updates []protocol.FileDownloadProgre
for _, update := range updates {
local, ok := p.files[update.Name]
if update.UpdateType == protocol.UpdateTypeForget && ok && local.version.Equal(update.Version) {
if update.UpdateType == protocol.FileDownloadProgressUpdateTypeForget && ok && local.version.Equal(update.Version) {
delete(p.files, update.Name)
} else if update.UpdateType == protocol.UpdateTypeAppend {
} else if update.UpdateType == protocol.FileDownloadProgressUpdateTypeAppend {
if !ok {
local = deviceFolderFileDownloadState{
blockIndexes: update.BlockIndexes,
@@ -137,7 +137,7 @@ func (t *deviceDownloadState) Update(folder string, updates []protocol.FileDownl
// Has returns whether block at that specific index, and that specific version of the file
// is currently available on the remote device for pulling from a temporary file.
func (t *deviceDownloadState) Has(folder, file string, version protocol.Vector, index int32) bool {
func (t *deviceDownloadState) Has(folder, file string, version protocol.Vector, index int) bool {
if t == nil {
return false
}
+9 -9
View File
@@ -17,16 +17,16 @@ func TestDeviceDownloadState(t *testing.T) {
v2 := (protocol.Vector{}).Update(1)
// file 1 version 1 part 1
f1v1p1 := protocol.FileDownloadProgressUpdate{UpdateType: protocol.UpdateTypeAppend, Name: "f1", Version: v1, BlockIndexes: []int32{0, 1, 2}}
f1v1p2 := protocol.FileDownloadProgressUpdate{UpdateType: protocol.UpdateTypeAppend, Name: "f1", Version: v1, BlockIndexes: []int32{3, 4, 5}}
f1v1del := protocol.FileDownloadProgressUpdate{UpdateType: protocol.UpdateTypeForget, Name: "f1", Version: v1, BlockIndexes: nil}
f1v2p1 := protocol.FileDownloadProgressUpdate{UpdateType: protocol.UpdateTypeAppend, Name: "f1", Version: v2, BlockIndexes: []int32{10, 11, 12}}
f1v2p2 := protocol.FileDownloadProgressUpdate{UpdateType: protocol.UpdateTypeAppend, Name: "f1", Version: v2, BlockIndexes: []int32{13, 14, 15}}
f1v2del := protocol.FileDownloadProgressUpdate{UpdateType: protocol.UpdateTypeForget, Name: "f1", Version: v2, BlockIndexes: nil}
f1v1p1 := protocol.FileDownloadProgressUpdate{UpdateType: protocol.FileDownloadProgressUpdateTypeAppend, Name: "f1", Version: v1, BlockIndexes: []int{0, 1, 2}}
f1v1p2 := protocol.FileDownloadProgressUpdate{UpdateType: protocol.FileDownloadProgressUpdateTypeAppend, Name: "f1", Version: v1, BlockIndexes: []int{3, 4, 5}}
f1v1del := protocol.FileDownloadProgressUpdate{UpdateType: protocol.FileDownloadProgressUpdateTypeForget, Name: "f1", Version: v1, BlockIndexes: nil}
f1v2p1 := protocol.FileDownloadProgressUpdate{UpdateType: protocol.FileDownloadProgressUpdateTypeAppend, Name: "f1", Version: v2, BlockIndexes: []int{10, 11, 12}}
f1v2p2 := protocol.FileDownloadProgressUpdate{UpdateType: protocol.FileDownloadProgressUpdateTypeAppend, Name: "f1", Version: v2, BlockIndexes: []int{13, 14, 15}}
f1v2del := protocol.FileDownloadProgressUpdate{UpdateType: protocol.FileDownloadProgressUpdateTypeForget, Name: "f1", Version: v2, BlockIndexes: nil}
f2v1p1 := protocol.FileDownloadProgressUpdate{UpdateType: protocol.UpdateTypeAppend, Name: "f2", Version: v1, BlockIndexes: []int32{20, 21, 22}}
f2v1p2 := protocol.FileDownloadProgressUpdate{UpdateType: protocol.UpdateTypeAppend, Name: "f2", Version: v1, BlockIndexes: []int32{23, 24, 25}}
f2v1del := protocol.FileDownloadProgressUpdate{UpdateType: protocol.UpdateTypeForget, Name: "f2", Version: v1, BlockIndexes: nil}
f2v1p1 := protocol.FileDownloadProgressUpdate{UpdateType: protocol.FileDownloadProgressUpdateTypeAppend, Name: "f2", Version: v1, BlockIndexes: []int{20, 21, 22}}
f2v1p2 := protocol.FileDownloadProgressUpdate{UpdateType: protocol.FileDownloadProgressUpdateTypeAppend, Name: "f2", Version: v1, BlockIndexes: []int{23, 24, 25}}
f2v1del := protocol.FileDownloadProgressUpdate{UpdateType: protocol.FileDownloadProgressUpdateTypeForget, Name: "f2", Version: v1, BlockIndexes: nil}
tests := []struct {
updates []protocol.FileDownloadProgressUpdate
+1 -1
View File
@@ -129,7 +129,7 @@ func (f *fakeConnection) addFileLocked(name string, flags uint32, ftype protocol
Permissions: flags,
Version: version,
Sequence: time.Now().UnixNano(),
RawBlockSize: int32(blockSize),
RawBlockSize: blockSize,
Blocks: blocks,
})
} else {
+1 -1
View File
@@ -431,7 +431,7 @@ func setupKnownFiles(t *testing.T, ffs fs.Filesystem, data []byte) []protocol.Fi
Permissions: 0644,
Size: fi.Size(),
ModifiedS: fi.ModTime().Unix(),
ModifiedNs: int32(fi.ModTime().UnixNano() % 1e9),
ModifiedNs: int(fi.ModTime().UnixNano() % 1e9),
Version: protocol.Vector{Counters: []protocol.Counter{{ID: 42, Value: 42}}},
Sequence: 42,
Blocks: blocks,
+2 -2
View File
@@ -1074,7 +1074,7 @@ func (f *sendReceiveFolder) handleFile(file protocol.FileInfo, snap *db.Snapshot
populateOffsets(file.Blocks)
blocks := make([]protocol.BlockInfo, 0, len(file.Blocks))
reused := make([]int32, 0, len(file.Blocks))
reused := make([]int, 0, len(file.Blocks))
// Check for an old temporary file which might have some blocks we could
// reuse.
@@ -1103,7 +1103,7 @@ func (f *sendReceiveFolder) handleFile(file protocol.FileInfo, snap *db.Snapshot
if !ok {
blocks = append(blocks, block)
} else {
reused = append(reused, int32(i))
reused = append(reused, i)
}
}
+1 -1
View File
@@ -357,7 +357,7 @@ func TestWeakHash(t *testing.T) {
Blocks: existing,
Size: size,
ModifiedS: info.ModTime().Unix(),
ModifiedNs: int32(info.ModTime().Nanosecond()),
ModifiedNs: info.ModTime().Nanosecond(),
}
desiredFile := protocol.FileInfo{
Name: "weakhash",
+5 -5
View File
@@ -712,9 +712,9 @@ type FolderCompletion struct {
CompletionPct float64
GlobalBytes int64
NeedBytes int64
GlobalItems int32
NeedItems int32
NeedDeletes int32
GlobalItems int
NeedItems int
NeedDeletes int
Sequence int64
}
@@ -2430,7 +2430,7 @@ next:
}
for _, device := range cfg.Devices {
if m.deviceDownloads[device.DeviceID].Has(folder, file.Name, file.Version, int32(block.Offset/int64(file.BlockSize()))) {
if m.deviceDownloads[device.DeviceID].Has(folder, file.Name, file.Version, int(block.Offset/int64(file.BlockSize()))) {
availabilities = append(availabilities, Availability{ID: device.DeviceID, FromTemporary: true})
}
}
@@ -2633,7 +2633,7 @@ func makeForgetUpdate(files []protocol.FileInfo) []protocol.FileDownloadProgress
updates = append(updates, protocol.FileDownloadProgressUpdate{
Name: file.Name,
Version: file.Version,
UpdateType: protocol.UpdateTypeForget,
UpdateType: protocol.FileDownloadProgressUpdateTypeForget,
})
}
return updates
+1 -1
View File
@@ -3331,7 +3331,7 @@ func TestConnCloseOnRestart(t *testing.T) {
br := &testutils.BlockingRW{}
nw := &testutils.NoopRW{}
m.AddConnection(newFakeProtoConn(protocol.NewConnection(device1, br, nw, m, "testConn", protocol.CompressNever)), protocol.Hello{})
m.AddConnection(newFakeProtoConn(protocol.NewConnection(device1, br, nw, m, "testConn", protocol.CompressionNever)), protocol.Hello{})
m.pmut.RLock()
if len(m.closed) != 1 {
t.Fatalf("Expected just one conn (len(m.conn) == %v)", len(m.conn))
+38 -38
View File
@@ -128,7 +128,7 @@ func TestSendDownloadProgressMessages(t *testing.T) {
p.registry["folder2"] = make(map[string]*sharedPullerState)
p.registry["folderXXX"] = make(map[string]*sharedPullerState)
expect := func(updateIdx int, state *sharedPullerState, updateType protocol.FileDownloadProgressUpdateType, version protocol.Vector, blocks []int32, remove bool) {
expect := func(updateIdx int, state *sharedPullerState, updateType protocol.FileDownloadProgressUpdateType, version protocol.Vector, blocks []int, remove bool) {
messageIdx := -1
for i, msg := range fc.downloadProgressMessages {
if msg.folder == state.folder {
@@ -222,10 +222,10 @@ func TestSendDownloadProgressMessages(t *testing.T) {
expectEmpty()
// Returns update for puller with new extra blocks
state1.available = []int32{1}
state1.available = []int{1}
sendMsgs(p)
expect(0, state1, protocol.UpdateTypeAppend, v1, []int32{1}, true)
expect(0, state1, protocol.FileDownloadProgressUpdateTypeAppend, v1, []int{1}, true)
expectEmpty()
// Does nothing if nothing changes
@@ -239,7 +239,7 @@ func TestSendDownloadProgressMessages(t *testing.T) {
expectEmpty()
// Does not return an update if date blocks change but date does not (should never happen)
state1.available = []int32{1, 2}
state1.available = []int{1, 2}
sendMsgs(p)
expectEmpty()
@@ -249,7 +249,7 @@ func TestSendDownloadProgressMessages(t *testing.T) {
sendMsgs(p)
expect(0, state1, protocol.UpdateTypeAppend, v1, []int32{2}, true)
expect(0, state1, protocol.FileDownloadProgressUpdateTypeAppend, v1, []int{2}, true)
expectEmpty()
// Returns forget and update if puller version has changed
@@ -257,20 +257,20 @@ func TestSendDownloadProgressMessages(t *testing.T) {
sendMsgs(p)
expect(0, state1, protocol.UpdateTypeForget, v1, nil, false)
expect(1, state1, protocol.UpdateTypeAppend, v2, []int32{1, 2}, true)
expect(0, state1, protocol.FileDownloadProgressUpdateTypeForget, v1, nil, false)
expect(1, state1, protocol.FileDownloadProgressUpdateTypeAppend, v2, []int{1, 2}, true)
expectEmpty()
// Returns forget and append if sharedPullerState creation timer changes.
state1.available = []int32{1}
state1.available = []int{1}
state1.availableUpdated = tick()
state1.created = tick()
sendMsgs(p)
expect(0, state1, protocol.UpdateTypeForget, v2, nil, false)
expect(1, state1, protocol.UpdateTypeAppend, v2, []int32{1}, true)
expect(0, state1, protocol.FileDownloadProgressUpdateTypeForget, v2, nil, false)
expect(1, state1, protocol.FileDownloadProgressUpdateTypeAppend, v2, []int{1}, true)
expectEmpty()
// Sends an empty update if new file exists, but does not have any blocks yet. (To indicate that the old blocks are no longer available)
@@ -280,12 +280,12 @@ func TestSendDownloadProgressMessages(t *testing.T) {
sendMsgs(p)
expect(0, state1, protocol.UpdateTypeForget, v2, nil, false)
expect(1, state1, protocol.UpdateTypeAppend, v1, nil, true)
expect(0, state1, protocol.FileDownloadProgressUpdateTypeForget, v2, nil, false)
expect(1, state1, protocol.FileDownloadProgressUpdateTypeAppend, v1, nil, true)
expectEmpty()
// Updates for multiple files and folders can be combined
state1.available = []int32{1, 2, 3}
state1.available = []int{1, 2, 3}
state1.availableUpdated = tick()
state2 := &sharedPullerState{
@@ -296,7 +296,7 @@ func TestSendDownloadProgressMessages(t *testing.T) {
Blocks: blocks,
},
mut: sync.NewRWMutex(),
available: []int32{1, 2, 3},
available: []int{1, 2, 3},
availableUpdated: time.Now(),
}
state3 := &sharedPullerState{
@@ -307,7 +307,7 @@ func TestSendDownloadProgressMessages(t *testing.T) {
Blocks: blocks,
},
mut: sync.NewRWMutex(),
available: []int32{1, 2, 3},
available: []int{1, 2, 3},
availableUpdated: time.Now(),
}
state4 := &sharedPullerState{
@@ -318,7 +318,7 @@ func TestSendDownloadProgressMessages(t *testing.T) {
Blocks: blocks,
},
mut: sync.NewRWMutex(),
available: []int32{1, 2, 3},
available: []int{1, 2, 3},
availableUpdated: time.Now(),
}
p.registry["folder2"]["2"] = state2
@@ -327,16 +327,16 @@ func TestSendDownloadProgressMessages(t *testing.T) {
sendMsgs(p)
expect(-1, state1, protocol.UpdateTypeAppend, v1, []int32{1, 2, 3}, false)
expect(-1, state3, protocol.UpdateTypeAppend, v1, []int32{1, 2, 3}, true)
expect(-1, state2, protocol.UpdateTypeAppend, v1, []int32{1, 2, 3}, false)
expect(-1, state4, protocol.UpdateTypeAppend, v1, []int32{1, 2, 3}, true)
expect(-1, state1, protocol.FileDownloadProgressUpdateTypeAppend, v1, []int{1, 2, 3}, false)
expect(-1, state3, protocol.FileDownloadProgressUpdateTypeAppend, v1, []int{1, 2, 3}, true)
expect(-1, state2, protocol.FileDownloadProgressUpdateTypeAppend, v1, []int{1, 2, 3}, false)
expect(-1, state4, protocol.FileDownloadProgressUpdateTypeAppend, v1, []int{1, 2, 3}, true)
expectEmpty()
// Returns forget if puller no longer exists, as well as updates if it has been updated.
state1.available = []int32{1, 2, 3, 4, 5}
state1.available = []int{1, 2, 3, 4, 5}
state1.availableUpdated = tick()
state2.available = []int32{1, 2, 3, 4, 5}
state2.available = []int{1, 2, 3, 4, 5}
state2.availableUpdated = tick()
delete(p.registry["folder"], "3")
@@ -344,10 +344,10 @@ func TestSendDownloadProgressMessages(t *testing.T) {
sendMsgs(p)
expect(-1, state1, protocol.UpdateTypeAppend, v1, []int32{4, 5}, false)
expect(-1, state3, protocol.UpdateTypeForget, v1, nil, true)
expect(-1, state2, protocol.UpdateTypeAppend, v1, []int32{4, 5}, false)
expect(-1, state4, protocol.UpdateTypeForget, v1, nil, true)
expect(-1, state1, protocol.FileDownloadProgressUpdateTypeAppend, v1, []int{4, 5}, false)
expect(-1, state3, protocol.FileDownloadProgressUpdateTypeForget, v1, nil, true)
expect(-1, state2, protocol.FileDownloadProgressUpdateTypeAppend, v1, []int{4, 5}, false)
expect(-1, state4, protocol.FileDownloadProgressUpdateTypeForget, v1, nil, true)
expectEmpty()
// Deletions are sent only once (actual bug I found writing the tests)
@@ -366,7 +366,7 @@ func TestSendDownloadProgressMessages(t *testing.T) {
Blocks: blocks,
},
mut: sync.NewRWMutex(),
available: []int32{1, 2, 3},
available: []int{1, 2, 3},
availableUpdated: time.Now(),
}
// Symlink
@@ -378,7 +378,7 @@ func TestSendDownloadProgressMessages(t *testing.T) {
Type: protocol.FileInfoTypeSymlink,
},
mut: sync.NewRWMutex(),
available: []int32{1, 2, 3},
available: []int{1, 2, 3},
availableUpdated: time.Now(),
}
// Some other directory
@@ -390,7 +390,7 @@ func TestSendDownloadProgressMessages(t *testing.T) {
Blocks: blocks,
},
mut: sync.NewRWMutex(),
available: []int32{1, 2, 3},
available: []int{1, 2, 3},
availableUpdated: time.Now(),
}
// Less than 10 blocks
@@ -402,7 +402,7 @@ func TestSendDownloadProgressMessages(t *testing.T) {
Blocks: blocks[:3],
},
mut: sync.NewRWMutex(),
available: []int32{1, 2, 3},
available: []int{1, 2, 3},
availableUpdated: time.Now(),
}
p.registry["folder"]["5"] = state5
@@ -419,8 +419,8 @@ func TestSendDownloadProgressMessages(t *testing.T) {
delete(p.registry["folder2"], "2") // Clean up first
sendMsgs(p)
expect(-1, state1, protocol.UpdateTypeForget, v1, nil, true)
expect(-1, state2, protocol.UpdateTypeForget, v1, nil, true)
expect(-1, state1, protocol.FileDownloadProgressUpdateTypeForget, v1, nil, true)
expect(-1, state2, protocol.FileDownloadProgressUpdateTypeForget, v1, nil, true)
expectEmpty()
@@ -431,10 +431,10 @@ func TestSendDownloadProgressMessages(t *testing.T) {
sendMsgs(p)
expect(-1, state1, protocol.UpdateTypeAppend, v1, []int32{1, 2, 3, 4, 5}, false)
expect(-1, state3, protocol.UpdateTypeAppend, v1, []int32{1, 2, 3}, true)
expect(-1, state2, protocol.UpdateTypeAppend, v1, []int32{1, 2, 3, 4, 5}, false)
expect(-1, state4, protocol.UpdateTypeAppend, v1, []int32{1, 2, 3}, true)
expect(-1, state1, protocol.FileDownloadProgressUpdateTypeAppend, v1, []int{1, 2, 3, 4, 5}, false)
expect(-1, state3, protocol.FileDownloadProgressUpdateTypeAppend, v1, []int{1, 2, 3}, true)
expect(-1, state2, protocol.FileDownloadProgressUpdateTypeAppend, v1, []int{1, 2, 3, 4, 5}, false)
expect(-1, state4, protocol.FileDownloadProgressUpdateTypeAppend, v1, []int{1, 2, 3}, true)
expectEmpty()
p.temporaryIndexUnsubscribe(fc)
@@ -444,8 +444,8 @@ func TestSendDownloadProgressMessages(t *testing.T) {
// See progressemitter.go for explanation why this is commented out.
// Search for state.cleanup
//expect(-1, state2, protocol.UpdateTypeForget, v1, nil, false)
//expect(-1, state4, protocol.UpdateTypeForget, v1, nil, true)
//expect(-1, state2, protocol.FileDownloadProgressUpdateTypeForget, v1, nil, false)
//expect(-1, state4, protocol.FileDownloadProgressUpdateTypeForget, v1, nil, true)
expectEmpty()
+9 -9
View File
@@ -15,7 +15,7 @@ import (
// sentFolderFileDownloadState represents a state of what we've announced as available
// to some remote device for a specific file.
type sentFolderFileDownloadState struct {
blockIndexes []int32
blockIndexes []int
version protocol.Vector
updated time.Time
created time.Time
@@ -44,7 +44,7 @@ func (s *sentFolderDownloadState) update(pullers []*sharedPullerState) []protoco
pullerVersion := puller.file.Version
pullerBlockIndexesUpdated := puller.AvailableUpdated()
pullerCreated := puller.created
pullerBlockSize := int32(puller.file.BlockSize())
pullerBlockSize := puller.file.BlockSize()
localFile, ok := s.files[name]
@@ -57,13 +57,13 @@ func (s *sentFolderDownloadState) update(pullers []*sharedPullerState) []protoco
updated: pullerBlockIndexesUpdated,
version: pullerVersion,
created: pullerCreated,
blockSize: int(pullerBlockSize),
blockSize: pullerBlockSize,
}
updates = append(updates, protocol.FileDownloadProgressUpdate{
Name: name,
Version: pullerVersion,
UpdateType: protocol.UpdateTypeAppend,
UpdateType: protocol.FileDownloadProgressUpdateTypeAppend,
BlockIndexes: pullerBlockIndexes,
BlockSize: pullerBlockSize,
})
@@ -83,12 +83,12 @@ func (s *sentFolderDownloadState) update(pullers []*sharedPullerState) []protoco
updates = append(updates, protocol.FileDownloadProgressUpdate{
Name: name,
Version: localFile.version,
UpdateType: protocol.UpdateTypeForget,
UpdateType: protocol.FileDownloadProgressUpdateTypeForget,
})
updates = append(updates, protocol.FileDownloadProgressUpdate{
Name: name,
Version: pullerVersion,
UpdateType: protocol.UpdateTypeAppend,
UpdateType: protocol.FileDownloadProgressUpdateTypeAppend,
BlockIndexes: pullerBlockIndexes,
BlockSize: pullerBlockSize,
})
@@ -112,7 +112,7 @@ func (s *sentFolderDownloadState) update(pullers []*sharedPullerState) []protoco
updates = append(updates, protocol.FileDownloadProgressUpdate{
Name: name,
Version: localFile.version,
UpdateType: protocol.UpdateTypeAppend,
UpdateType: protocol.FileDownloadProgressUpdateTypeAppend,
BlockIndexes: newBlocks,
BlockSize: pullerBlockSize,
})
@@ -127,7 +127,7 @@ func (s *sentFolderDownloadState) update(pullers []*sharedPullerState) []protoco
updates = append(updates, protocol.FileDownloadProgressUpdate{
Name: name,
Version: info.version,
UpdateType: protocol.UpdateTypeForget,
UpdateType: protocol.FileDownloadProgressUpdateTypeForget,
})
delete(s.files, name)
}
@@ -144,7 +144,7 @@ func (s *sentFolderDownloadState) destroy() []protocol.FileDownloadProgressUpdat
updates = append(updates, protocol.FileDownloadProgressUpdate{
Name: name,
Version: info.version,
UpdateType: protocol.UpdateTypeForget,
UpdateType: protocol.FileDownloadProgressUpdateTypeForget,
})
delete(s.files, name)
}
+5 -5
View File
@@ -44,12 +44,12 @@ type sharedPullerState struct {
pullNeeded int // Number of block pulls still pending
updated time.Time // Time when any of the counters above were last updated
closed bool // True if the file has been finalClosed.
available []int32 // Indexes of the blocks that are available in the temporary file
available []int // Indexes of the blocks that are available in the temporary file
availableUpdated time.Time // Time when list of available blocks was last updated
mut sync.RWMutex // Protects the above
}
func newSharedPullerState(file protocol.FileInfo, fs fs.Filesystem, folderID, tempName string, blocks []protocol.BlockInfo, reused []int32, ignorePerms, hasCurFile bool, curFile protocol.FileInfo, sparse bool, fsync bool) *sharedPullerState {
func newSharedPullerState(file protocol.FileInfo, fs fs.Filesystem, folderID, tempName string, blocks []protocol.BlockInfo, reused []int, ignorePerms, hasCurFile bool, curFile protocol.FileInfo, sparse bool, fsync bool) *sharedPullerState {
return &sharedPullerState{
file: file,
fs: fs,
@@ -244,7 +244,7 @@ func (s *sharedPullerState) copyDone(block protocol.BlockInfo) {
s.mut.Lock()
s.copyNeeded--
s.updated = time.Now()
s.available = append(s.available, int32(block.Offset/int64(s.file.BlockSize())))
s.available = append(s.available, int(block.Offset/int64(s.file.BlockSize())))
s.availableUpdated = time.Now()
l.Debugln("sharedPullerState", s.folder, s.file.Name, "copyNeeded ->", s.copyNeeded)
s.mut.Unlock()
@@ -280,7 +280,7 @@ func (s *sharedPullerState) pullDone(block protocol.BlockInfo) {
s.mut.Lock()
s.pullNeeded--
s.updated = time.Now()
s.available = append(s.available, int32(block.Offset/int64(s.file.BlockSize())))
s.available = append(s.available, int(block.Offset/int64(s.file.BlockSize())))
s.availableUpdated = time.Now()
l.Debugln("sharedPullerState", s.folder, s.file.Name, "pullNeeded done ->", s.pullNeeded)
s.mut.Unlock()
@@ -359,7 +359,7 @@ func (s *sharedPullerState) AvailableUpdated() time.Time {
}
// Available returns blocks available in the current temporary file
func (s *sharedPullerState) Available() []int32 {
func (s *sharedPullerState) Available() []int {
s.mut.RLock()
blocks := s.available
s.mut.RUnlock()