fix: bt fetcher restore

This commit is contained in:
liwei committed 2023-02-06 22:21:25 +08:00
1 parent 027d29e834
commit 2e5fd3017c
3 files changed
+12 -4

No files matched your search

+3 -1
View File
@@ -281,6 +281,7 @@ func (d *Downloader) Continue(id string) (err error) {
defer task.lock.Unlock()
if task.Status == base.DownloadStatusPause || task.Status == base.DownloadStatusError {
task.Status = base.DownloadStatusRunning
task.Progress.Speed = 0
err = d.restoreFetcher(task)
if err != nil {
return
@@ -418,6 +419,7 @@ func (d *Downloader) getProtocolConfig(name string, v any) (bool, error) {
return true, nil
}
// wait task done
func (d *Downloader) watch(task *Task) {
err := task.fetcher.Wait()
if err != nil {
@@ -456,8 +458,8 @@ func (d *Downloader) restoreFetcher(task *Task) error {
if err != nil {
return err
}
task.fetcher = f(task.Meta, v)
}
task.fetcher = f(task.Meta, v)
return nil
}()
if err != nil {
+3 -1
View File
@@ -21,5 +21,7 @@ func WriteJsonOk(w http.ResponseWriter, v any) {
func WriteJson(w http.ResponseWriter, code int, v any) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(code)
json.NewEncoder(w).Encode(v)
if v != nil {
json.NewEncoder(w).Encode(v)
}
}