MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / CancelDownloadTask

Function CancelDownloadTask

service/explorer/workflows.go:398–414  ·  view source on GitHub ↗
(c *gin.Context, taskID int)

Source from the content-addressed store, hash-verified

396}
397
398func CancelDownloadTask(c *gin.Context, taskID int) error {
399 dep := dependency.FromContext(c)
400 u := inventory.UserFromContext(c)
401 r := dep.TaskRegistry()
402 t, found := r.Get(taskID)
403 if !found || t.Owner().ID != u.ID {
404 return serializer.NewError(serializer.CodeNotFound, "Task not found", nil)
405 }
406
407 if downloadTask, ok := t.(*workflows.RemoteDownloadTask); ok {
408 if err := downloadTask.CancelDownload(c); err != nil {
409 return serializer.NewError(serializer.CodeInternalSetting, "Failed to cancel download task", err)
410 }
411 }
412
413 return nil
414}
415
416type (
417 SetDownloadFilesService struct {

Callers 1

CancelDownloadTaskFunction · 0.92

Calls 7

FromContextFunction · 0.92
UserFromContextFunction · 0.92
NewErrorFunction · 0.92
CancelDownloadMethod · 0.80
TaskRegistryMethod · 0.65
GetMethod · 0.65
OwnerMethod · 0.65

Tested by

no test coverage detected