diff --git a/zboxcore/sdk/allocation.go b/zboxcore/sdk/allocation.go index 649d554cf..a1d9c8d56 100644 --- a/zboxcore/sdk/allocation.go +++ b/zboxcore/sdk/allocation.go @@ -1151,6 +1151,9 @@ func (a *Allocation) processReadMarker(drs []*DownloadRequest) { wg.Add(1) go func(dr *DownloadRequest) { defer wg.Done() + if isReadFree { + dr.freeRead = true + } dr.processDownloadRequest() var pos uint64 if !dr.skip { diff --git a/zboxcore/sdk/downloadworker.go b/zboxcore/sdk/downloadworker.go index 2937e2644..1cf1a06ec 100644 --- a/zboxcore/sdk/downloadworker.go +++ b/zboxcore/sdk/downloadworker.go @@ -80,6 +80,7 @@ type DownloadRequest struct { size int64 offset int64 bufferMap map[int]*zboxutil.DownloadBuffer + freeRead bool } type blockData struct { @@ -179,7 +180,11 @@ func (req *DownloadRequest) downloadBlock( skipDownload bool ) - for i := req.downloadMask; !i.Equals64(0); i = i.And(zboxutil.NewUint128(1).Lsh(pos).Not()) { + for i := mask; !i.Equals64(0); i = i.And(zboxutil.NewUint128(1).Lsh(pos).Not()) { + if c == requiredDownloads { + remainingMask = i + break + } pos = uint64(i.TrailingZeros()) blockDownloadReq := &BlockDownloadRequest{ allocationID: req.allocationID, @@ -220,10 +225,6 @@ func (req *DownloadRequest) downloadBlock( } c++ - if c == requiredDownloads { - remainingMask = i - break - } } var failed int32 @@ -1025,6 +1026,9 @@ func (req *DownloadRequest) getFileMetaConsensus(fMetaResp []*fileMetaResponse) if countThreshold > req.fullconsensus { countThreshold = req.consensusThresh } + if req.freeRead { + countThreshold = req.fullconsensus + } for i := 0; i < len(fMetaResp); i++ { fmr := fMetaResp[i] if fmr.err != nil || fmr.fileref == nil {