Skip to content

Commit

Permalink
fix last block size
Browse files Browse the repository at this point in the history
  • Loading branch information
Hitenjain14 committed Feb 4, 2024
1 parent 4997432 commit 0fcc866
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions zboxcore/sdk/downloadworker.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,6 @@ func (req *DownloadRequest) processDownload(ctx context.Context) {
// Buffered channel to hold the blocks as they are downloaded
blocks := make(chan blockData, n)

lastBlockSize := size - int64(n-1)*int64(req.effectiveBlockSize)*int64(req.datashards)*numBlocks

var (
actualFileHasher hash.Hash
isPREAndWholeFile bool
Expand Down Expand Up @@ -652,7 +650,7 @@ func (req *DownloadRequest) processDownload(ctx context.Context) {
offset := (startBlock + int64(j)*numBlocks) * int64(req.effectiveBlockSize) * int64(req.datashards)
var total int
if j == n-1 {
total, err = writeAtData(writeAtHandler, data, req.datashards, offset, int(lastBlockSize))
total, err = writeAtData(writeAtHandler, data, req.datashards, offset, int(size-offset))
} else {
total, err = writeAtData(writeAtHandler, data, req.datashards, offset, -1)
}
Expand Down

0 comments on commit 0fcc866

Please sign in to comment.