lib/model: Adjust blocks reported in usage reporting (fixes #5995) (#6037)

* lib/model: Adjust blocks reported in usage reporting (fixes #5995)

* Use variables, fix go.mod
This commit is contained in:
Audrius Butkevicius
2019-10-04 12:03:13 +01:00
committed by GitHub
parent 5e31e6356f
commit 8fb576ed54
2 changed files with 10 additions and 12 deletions

View File

@@ -982,8 +982,9 @@ func (f *sendReceiveFolder) renameFile(cur, source, target protocol.FileInfo, db
}
blockStatsMut.Lock()
blockStats["total"] += len(target.Blocks)
blockStats["renamed"] += len(target.Blocks)
minBlocksPerBlock := target.BlockSize() / protocol.MinBlockSize
blockStats["total"] += len(target.Blocks) * minBlocksPerBlock
blockStats["renamed"] += len(target.Blocks) * minBlocksPerBlock
blockStatsMut.Unlock()
// The file was renamed, so we have handled both the necessary delete
@@ -1559,15 +1560,16 @@ func (f *sendReceiveFolder) finisherRoutine(in <-chan *sharedPullerState, dbUpda
if err != nil {
f.newPullError(state.file.Name, err)
} else {
minBlocksPerBlock := state.file.BlockSize() / protocol.MinBlockSize
blockStatsMut.Lock()
blockStats["total"] += state.reused + state.copyTotal + state.pullTotal
blockStats["reused"] += state.reused
blockStats["pulled"] += state.pullTotal
blockStats["total"] += (state.reused + state.copyTotal + state.pullTotal) * minBlocksPerBlock
blockStats["reused"] += state.reused * minBlocksPerBlock
blockStats["pulled"] += state.pullTotal * minBlocksPerBlock
// copyOriginShifted is counted towards copyOrigin due to progress bar reasons
// for reporting reasons we want to separate these.
blockStats["copyOrigin"] += state.copyOrigin - state.copyOriginShifted
blockStats["copyOriginShifted"] += state.copyOriginShifted
blockStats["copyElsewhere"] += state.copyTotal - state.copyOrigin
blockStats["copyOrigin"] += (state.copyOrigin - state.copyOriginShifted) * minBlocksPerBlock
blockStats["copyOriginShifted"] += state.copyOriginShifted * minBlocksPerBlock
blockStats["copyElsewhere"] += (state.copyTotal - state.copyOrigin) * minBlocksPerBlock
blockStatsMut.Unlock()
}