Skip to content

Commit

Permalink
downloader: add deadline
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Mar 11, 2024
1 parent fefb435 commit ebd0176
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions renterd/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (br *blockResponse) block(ctx context.Context, c cid.Cid) (blocks.Block, er

func (bd *BlockDownloader) doDownloadTask(task *blockResponse, log *zap.Logger) {
log = log.Named("doDownloadTask").With(zap.Stringer("cid", task.cid), zap.Stringer("priority", task.priority))
blockBuf := bytes.NewBuffer(make([]byte, 0, 1<<20))
blockBuf := bytes.NewBuffer(make([]byte, 0, 2<<20))

start := time.Now()
bucket, key, err := bd.store.BlockLocation(task.cid)
Expand All @@ -148,7 +148,10 @@ func (bd *BlockDownloader) doDownloadTask(task *blockResponse, log *zap.Logger)
return
}

err = bd.workerClient.DownloadObject(context.Background(), blockBuf, bucket, key, api.DownloadObjectOptions{})
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

err = bd.workerClient.DownloadObject(ctx, blockBuf, bucket, key, api.DownloadObjectOptions{})
if err != nil {
if !format.IsNotFound(err) {
log.Error("failed to download block", zap.Error(err))
Expand Down

0 comments on commit ebd0176

Please sign in to comment.