From e89a9450e94295c89cf6583fd4b204c83e9883b7 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 9 Mar 2024 16:55:10 -0500 Subject: [PATCH] fix: don't tie contexts to tus http context --- protocols/s5/tus.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/protocols/s5/tus.go b/protocols/s5/tus.go index 50d8cf3..b432571 100644 --- a/protocols/s5/tus.go +++ b/protocols/s5/tus.go @@ -445,7 +445,7 @@ func (t *TusHandler) uploadTask(hash []byte) error { } func (t *TusHandler) worker() { - + ctx := context.Background() for { select { case info := <-t.tus.CreatedUploads: @@ -475,7 +475,7 @@ func (t *TusHandler) worker() { continue } - _, err = t.CreateUpload(info.Context, decodedHash.HashBytes(), info.Upload.ID, uploaderID, uploaderIP, t.storageProtocol.Name()) + _, err = t.CreateUpload(ctx, decodedHash.HashBytes(), info.Upload.ID, uploaderID, uploaderIP, t.storageProtocol.Name()) if err != nil { errorResponse.Body = "Could not create tus upload" info.Upload.StopUpload(errorResponse) @@ -483,13 +483,13 @@ func (t *TusHandler) worker() { continue } case info := <-t.tus.UploadProgress: - err := t.UploadProgress(info.Context, info.Upload.ID) + err := t.UploadProgress(ctx, info.Upload.ID) if err != nil { t.logger.Error("Could not update tus upload", zap.Error(err)) continue } case info := <-t.tus.TerminatedUploads: - err := t.DeleteUpload(info.Context, info.Upload.ID) + err := t.DeleteUpload(ctx, info.Upload.ID) if err != nil { t.logger.Error("Could not delete tus upload", zap.Error(err)) continue @@ -499,12 +499,12 @@ func (t *TusHandler) worker() { if !(!info.Upload.SizeIsDeferred && info.Upload.Offset == info.Upload.Size) { continue } - err := t.UploadCompleted(info.Context, info.Upload.ID) + err := t.UploadCompleted(ctx, info.Upload.ID) if err != nil { t.logger.Error("Could not complete tus upload", zap.Error(err)) continue } - err = t.ScheduleUpload(info.Context, info.Upload.ID) + err = t.ScheduleUpload(ctx, info.Upload.ID) if err != nil { t.logger.Error("Could not schedule tus upload", zap.Error(err)) continue