Skip to content

Commit

Permalink
Merge pull request #1491 from 0chain/hotfix/ctx-err
Browse files Browse the repository at this point in the history
Return ctx err
  • Loading branch information
dabasov authored May 25, 2024
2 parents e5a796e + d4e1ad5 commit 99de129
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions zboxcore/sdk/allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2341,8 +2341,10 @@ func (a *Allocation) PauseUpload(remotePath string) error {
cancelFunc, ok := CancelOpCtx[remotePath]
cancelLock.Unlock()
if !ok {
logger.Logger.Error("PauseUpload: remote path not found", remotePath)
return errors.New("remote_path_not_found", "Invalid path. No upload in progress for the path "+remotePath)
} else {
logger.Logger.Info("PauseUpload: remote path found", remotePath)
cancelFunc(ErrPauseUpload)
}
return nil
Expand Down
4 changes: 4 additions & 0 deletions zboxcore/sdk/chunked_upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ func (su *ChunkedUpload) processUpload(chunkStartIndex, chunkEndIndex int,
su.removeProgress()
return thrown.New("upload_failed", fmt.Sprintf("Upload failed. %s", err))
}
logger.Logger.Info("uploadingData: ", blobberUpload.chunkStartIndex, " - ", blobberUpload.chunkEndIndex, " ", isFinal, " ", su.fileMeta.RemotePath)
if !lastBufferOnly {
su.uploadWG.Add(1)
select {
Expand All @@ -716,7 +717,9 @@ func (su *ChunkedUpload) processUpload(chunkStartIndex, chunkEndIndex int,

if isFinal {
close(su.uploadChan)
logger.Logger.Info("Waiting for upload to complete")
su.uploadWG.Wait()
logger.Logger.Info("Upload completed")
select {
case <-su.ctx.Done():
return context.Cause(su.ctx)
Expand Down Expand Up @@ -817,6 +820,7 @@ func (su *ChunkedUpload) uploadProcessor() {
return
}
su.uploadToBlobbers(uploadData) //nolint:errcheck
logger.Logger.Info("upload_processor_complete: ", uploadData.chunkEndIndex, " ", uploadData.isFinal, " ", su.fileMeta.RemotePath)
su.uploadWG.Done()
}
}
Expand Down
6 changes: 5 additions & 1 deletion zboxcore/sdk/multi_operation_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,12 @@ func (mo *MultiOperation) Process() error {
}
swg.Wait()

if ctx.Err() != nil {
return context.Cause(ctx)
}

// Check consensus
if mo.operationMask.CountOnes() < mo.consensusThresh || ctx.Err() != nil {
if mo.operationMask.CountOnes() < mo.consensusThresh {
majorErr := zboxutil.MajorError(errsSlice)
if majorErr != nil {
return errors.New("consensus_not_met",
Expand Down

0 comments on commit 99de129

Please sign in to comment.