all: Combine sequential appends (#8461)

This commit is contained in:
Jakob Borg
2022-07-28 17:28:24 +02:00
committed by GitHub
parent f3835122bb
commit 388e4db9cd
2 changed files with 60 additions and 78 deletions
+13 -12
View File
@@ -80,18 +80,19 @@ func (s *sentFolderDownloadState) update(pullers []*sharedPullerState) []protoco
if !pullerVersion.Equal(localFile.version) || !pullerCreated.Equal(localFile.created) {
// The version has changed or the puller was reconstrcuted due to failure.
// Clean up whatever we had for the old file, and advertise the new file.
updates = append(updates, protocol.FileDownloadProgressUpdate{
Name: name,
Version: localFile.version,
UpdateType: protocol.FileDownloadProgressUpdateTypeForget,
})
updates = append(updates, protocol.FileDownloadProgressUpdate{
Name: name,
Version: pullerVersion,
UpdateType: protocol.FileDownloadProgressUpdateTypeAppend,
BlockIndexes: pullerBlockIndexes,
BlockSize: pullerBlockSize,
})
updates = append(updates,
protocol.FileDownloadProgressUpdate{
Name: name,
Version: localFile.version,
UpdateType: protocol.FileDownloadProgressUpdateTypeForget,
},
protocol.FileDownloadProgressUpdate{
Name: name,
Version: pullerVersion,
UpdateType: protocol.FileDownloadProgressUpdateTypeAppend,
BlockIndexes: pullerBlockIndexes,
BlockSize: pullerBlockSize,
})
localFile.blockIndexes = pullerBlockIndexes
localFile.updated = pullerBlockIndexesUpdated
localFile.version = pullerVersion