From aa9577a2e0601f7f18049b7c4a7123a73304ee89 Mon Sep 17 00:00:00 2001 From: liwei Date: Wed, 8 Feb 2023 14:53:49 +0800 Subject: [PATCH] fix: ignore broken task data --- pkg/download/downloader.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pkg/download/downloader.go b/pkg/download/downloader.go index 0dcd8615..1f77d517 100644 --- a/pkg/download/downloader.go +++ b/pkg/download/downloader.go @@ -14,8 +14,11 @@ import ( ) const ( - bucketTask = "task" - bucketSave = "save" + // task info bucket + bucketTask = "task" + // task download data bucket + bucketSave = "save" + // downloader config bucket bucketConfig = "config" ) @@ -77,7 +80,13 @@ func (d *Downloader) Setup() error { if tasks == nil { tasks = make([]*Task, 0) } else { - for _, task := range tasks { + for i := len(tasks) - 1; i >= 0; i-- { + task := tasks[i] + // Remove broken tasks + if task.Meta == nil { + tasks = append(tasks[:i], tasks[i+1:]...) + continue + } initTask(task) if task.Status != base.DownloadStatusDone && task.Status != base.DownloadStatusError { task.Status = base.DownloadStatusPause