mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-05 08:02:13 +00:00
lib/model: Remove unnecessary arguments in pulling functions (#5619)
This commit is contained in:
parent
3a557a43cd
commit
d4e81fff8a
@ -265,7 +265,7 @@ func (f *sendReceiveFolder) pullerIteration(scanChan chan<- string) int {
|
|||||||
doneWg.Done()
|
doneWg.Done()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
changed, fileDeletions, dirDeletions, err := f.processNeeded(dbUpdateChan, copyChan, finisherChan, scanChan)
|
changed, fileDeletions, dirDeletions, err := f.processNeeded(dbUpdateChan, copyChan, scanChan)
|
||||||
|
|
||||||
// Signal copy and puller routines that we are done with the in data for
|
// Signal copy and puller routines that we are done with the in data for
|
||||||
// this iteration. Wait for them to finish.
|
// this iteration. Wait for them to finish.
|
||||||
@ -290,7 +290,7 @@ func (f *sendReceiveFolder) pullerIteration(scanChan chan<- string) int {
|
|||||||
return changed
|
return changed
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *sendReceiveFolder) processNeeded(dbUpdateChan chan<- dbUpdateJob, copyChan chan<- copyBlocksState, finisherChan chan<- *sharedPullerState, scanChan chan<- string) (int, map[string]protocol.FileInfo, []protocol.FileInfo, error) {
|
func (f *sendReceiveFolder) processNeeded(dbUpdateChan chan<- dbUpdateJob, copyChan chan<- copyBlocksState, scanChan chan<- string) (int, map[string]protocol.FileInfo, []protocol.FileInfo, error) {
|
||||||
changed := 0
|
changed := 0
|
||||||
var processDirectly []protocol.FileInfo
|
var processDirectly []protocol.FileInfo
|
||||||
var dirDeletions []protocol.FileInfo
|
var dirDeletions []protocol.FileInfo
|
||||||
@ -488,7 +488,7 @@ nextFile:
|
|||||||
if _, ok := f.model.Connection(dev); ok {
|
if _, ok := f.model.Connection(dev); ok {
|
||||||
changed++
|
changed++
|
||||||
// Handle the file normally, by coping and pulling, etc.
|
// Handle the file normally, by coping and pulling, etc.
|
||||||
f.handleFile(fi, copyChan, finisherChan, dbUpdateChan)
|
f.handleFile(fi, copyChan, dbUpdateChan)
|
||||||
continue nextFile
|
continue nextFile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1017,7 +1017,7 @@ func (f *sendReceiveFolder) renameFile(cur, source, target protocol.FileInfo, db
|
|||||||
|
|
||||||
// handleFile queues the copies and pulls as necessary for a single new or
|
// handleFile queues the copies and pulls as necessary for a single new or
|
||||||
// changed file.
|
// changed file.
|
||||||
func (f *sendReceiveFolder) handleFile(file protocol.FileInfo, copyChan chan<- copyBlocksState, finisherChan chan<- *sharedPullerState, dbUpdateChan chan<- dbUpdateJob) {
|
func (f *sendReceiveFolder) handleFile(file protocol.FileInfo, copyChan chan<- copyBlocksState, dbUpdateChan chan<- dbUpdateJob) {
|
||||||
curFile, hasCurFile := f.fset.Get(protocol.LocalDeviceID, file.Name)
|
curFile, hasCurFile := f.fset.Get(protocol.LocalDeviceID, file.Name)
|
||||||
|
|
||||||
have, need := blockDiff(curFile.Blocks, file.Blocks)
|
have, need := blockDiff(curFile.Blocks, file.Blocks)
|
||||||
|
@ -145,7 +145,7 @@ func TestHandleFile(t *testing.T) {
|
|||||||
copyChan := make(chan copyBlocksState, 1)
|
copyChan := make(chan copyBlocksState, 1)
|
||||||
dbUpdateChan := make(chan dbUpdateJob, 1)
|
dbUpdateChan := make(chan dbUpdateJob, 1)
|
||||||
|
|
||||||
f.handleFile(requiredFile, copyChan, nil, dbUpdateChan)
|
f.handleFile(requiredFile, copyChan, dbUpdateChan)
|
||||||
|
|
||||||
// Receive the results
|
// Receive the results
|
||||||
toCopy := <-copyChan
|
toCopy := <-copyChan
|
||||||
@ -195,7 +195,7 @@ func TestHandleFileWithTemp(t *testing.T) {
|
|||||||
copyChan := make(chan copyBlocksState, 1)
|
copyChan := make(chan copyBlocksState, 1)
|
||||||
dbUpdateChan := make(chan dbUpdateJob, 1)
|
dbUpdateChan := make(chan dbUpdateJob, 1)
|
||||||
|
|
||||||
f.handleFile(requiredFile, copyChan, nil, dbUpdateChan)
|
f.handleFile(requiredFile, copyChan, dbUpdateChan)
|
||||||
|
|
||||||
// Receive the results
|
// Receive the results
|
||||||
toCopy := <-copyChan
|
toCopy := <-copyChan
|
||||||
@ -253,7 +253,7 @@ func TestCopierFinder(t *testing.T) {
|
|||||||
// Run a single fetcher routine
|
// Run a single fetcher routine
|
||||||
go f.copierRoutine(copyChan, pullChan, finisherChan)
|
go f.copierRoutine(copyChan, pullChan, finisherChan)
|
||||||
|
|
||||||
f.handleFile(requiredFile, copyChan, finisherChan, dbUpdateChan)
|
f.handleFile(requiredFile, copyChan, dbUpdateChan)
|
||||||
|
|
||||||
pulls := []pullBlockState{<-pullChan, <-pullChan, <-pullChan, <-pullChan}
|
pulls := []pullBlockState{<-pullChan, <-pullChan, <-pullChan, <-pullChan}
|
||||||
finish := <-finisherChan
|
finish := <-finisherChan
|
||||||
@ -374,7 +374,7 @@ func TestWeakHash(t *testing.T) {
|
|||||||
|
|
||||||
// Test 1 - no weak hashing, file gets fully repulled (`expectBlocks` pulls).
|
// Test 1 - no weak hashing, file gets fully repulled (`expectBlocks` pulls).
|
||||||
fo.WeakHashThresholdPct = 101
|
fo.WeakHashThresholdPct = 101
|
||||||
fo.handleFile(desiredFile, copyChan, finisherChan, dbUpdateChan)
|
fo.handleFile(desiredFile, copyChan, dbUpdateChan)
|
||||||
|
|
||||||
var pulls []pullBlockState
|
var pulls []pullBlockState
|
||||||
for len(pulls) < expectBlocks {
|
for len(pulls) < expectBlocks {
|
||||||
@ -402,7 +402,7 @@ func TestWeakHash(t *testing.T) {
|
|||||||
|
|
||||||
// Test 2 - using weak hash, expectPulls blocks pulled.
|
// Test 2 - using weak hash, expectPulls blocks pulled.
|
||||||
fo.WeakHashThresholdPct = -1
|
fo.WeakHashThresholdPct = -1
|
||||||
fo.handleFile(desiredFile, copyChan, finisherChan, dbUpdateChan)
|
fo.handleFile(desiredFile, copyChan, dbUpdateChan)
|
||||||
|
|
||||||
pulls = pulls[:0]
|
pulls = pulls[:0]
|
||||||
for len(pulls) < expectPulls {
|
for len(pulls) < expectPulls {
|
||||||
@ -493,7 +493,7 @@ func TestDeregisterOnFailInCopy(t *testing.T) {
|
|||||||
go f.copierRoutine(copyChan, pullChan, finisherBufferChan)
|
go f.copierRoutine(copyChan, pullChan, finisherBufferChan)
|
||||||
go f.finisherRoutine(finisherChan, dbUpdateChan, make(chan string))
|
go f.finisherRoutine(finisherChan, dbUpdateChan, make(chan string))
|
||||||
|
|
||||||
f.handleFile(file, copyChan, finisherChan, dbUpdateChan)
|
f.handleFile(file, copyChan, dbUpdateChan)
|
||||||
|
|
||||||
// Receive a block at puller, to indicate that at least a single copier
|
// Receive a block at puller, to indicate that at least a single copier
|
||||||
// loop has been performed.
|
// loop has been performed.
|
||||||
@ -584,7 +584,7 @@ func TestDeregisterOnFailInPull(t *testing.T) {
|
|||||||
go f.pullerRoutine(pullChan, finisherBufferChan)
|
go f.pullerRoutine(pullChan, finisherBufferChan)
|
||||||
go f.finisherRoutine(finisherChan, dbUpdateChan, make(chan string))
|
go f.finisherRoutine(finisherChan, dbUpdateChan, make(chan string))
|
||||||
|
|
||||||
f.handleFile(file, copyChan, finisherChan, dbUpdateChan)
|
f.handleFile(file, copyChan, dbUpdateChan)
|
||||||
|
|
||||||
// Receive at finisher, we should error out as puller has nowhere to pull
|
// Receive at finisher, we should error out as puller has nowhere to pull
|
||||||
// from.
|
// from.
|
||||||
@ -832,7 +832,7 @@ func TestCopyOwner(t *testing.T) {
|
|||||||
defer close(copierChan)
|
defer close(copierChan)
|
||||||
go f.copierRoutine(copierChan, nil, finisherChan)
|
go f.copierRoutine(copierChan, nil, finisherChan)
|
||||||
go f.finisherRoutine(finisherChan, dbUpdateChan, nil)
|
go f.finisherRoutine(finisherChan, dbUpdateChan, nil)
|
||||||
f.handleFile(file, copierChan, nil, nil)
|
f.handleFile(file, copierChan, nil)
|
||||||
<-dbUpdateChan
|
<-dbUpdateChan
|
||||||
|
|
||||||
info, err = f.fs.Lstat("foo/bar/baz")
|
info, err = f.fs.Lstat("foo/bar/baz")
|
||||||
|
Loading…
Reference in New Issue
Block a user