fix: don't tie contexts to tus http context
This commit is contained in:
parent
0c90924f31
commit
e89a9450e9
|
@ -445,7 +445,7 @@ func (t *TusHandler) uploadTask(hash []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TusHandler) worker() {
|
func (t *TusHandler) worker() {
|
||||||
|
ctx := context.Background()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case info := <-t.tus.CreatedUploads:
|
case info := <-t.tus.CreatedUploads:
|
||||||
|
@ -475,7 +475,7 @@ func (t *TusHandler) worker() {
|
||||||
continue
|
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 {
|
if err != nil {
|
||||||
errorResponse.Body = "Could not create tus upload"
|
errorResponse.Body = "Could not create tus upload"
|
||||||
info.Upload.StopUpload(errorResponse)
|
info.Upload.StopUpload(errorResponse)
|
||||||
|
@ -483,13 +483,13 @@ func (t *TusHandler) worker() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
case info := <-t.tus.UploadProgress:
|
case info := <-t.tus.UploadProgress:
|
||||||
err := t.UploadProgress(info.Context, info.Upload.ID)
|
err := t.UploadProgress(ctx, info.Upload.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.logger.Error("Could not update tus upload", zap.Error(err))
|
t.logger.Error("Could not update tus upload", zap.Error(err))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
case info := <-t.tus.TerminatedUploads:
|
case info := <-t.tus.TerminatedUploads:
|
||||||
err := t.DeleteUpload(info.Context, info.Upload.ID)
|
err := t.DeleteUpload(ctx, info.Upload.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.logger.Error("Could not delete tus upload", zap.Error(err))
|
t.logger.Error("Could not delete tus upload", zap.Error(err))
|
||||||
continue
|
continue
|
||||||
|
@ -499,12 +499,12 @@ func (t *TusHandler) worker() {
|
||||||
if !(!info.Upload.SizeIsDeferred && info.Upload.Offset == info.Upload.Size) {
|
if !(!info.Upload.SizeIsDeferred && info.Upload.Offset == info.Upload.Size) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
err := t.UploadCompleted(info.Context, info.Upload.ID)
|
err := t.UploadCompleted(ctx, info.Upload.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.logger.Error("Could not complete tus upload", zap.Error(err))
|
t.logger.Error("Could not complete tus upload", zap.Error(err))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
err = t.ScheduleUpload(info.Context, info.Upload.ID)
|
err = t.ScheduleUpload(ctx, info.Upload.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.logger.Error("Could not schedule tus upload", zap.Error(err))
|
t.logger.Error("Could not schedule tus upload", zap.Error(err))
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue