Modify: delete temp file inside monitor lifecycle

pull/247/head
HFO4 4 years ago
parent 096483b6ee
commit 356ac8d608

@ -5,7 +5,6 @@ import (
model "github.com/HFO4/cloudreve/models" model "github.com/HFO4/cloudreve/models"
"github.com/HFO4/cloudreve/pkg/util" "github.com/HFO4/cloudreve/pkg/util"
"github.com/zyxar/argo/rpc" "github.com/zyxar/argo/rpc"
"os"
"path/filepath" "path/filepath"
"strconv" "strconv"
"strings" "strings"
@ -51,17 +50,17 @@ func (client *RPCService) Cancel(task *model.Download) error {
util.Log().Warning("无法取消离线下载任务[%s], %s", task.GID, err) util.Log().Warning("无法取消离线下载任务[%s], %s", task.GID, err)
} }
// 删除临时文件 //// 删除临时文件
util.Log().Debug("离线下载任务[%s]已取消1 分钟后删除临时文件", task.GID) //util.Log().Debug("离线下载任务[%s]已取消1 分钟后删除临时文件", task.GID)
go func(task *model.Download) { //go func(task *model.Download) {
select { // select {
case <-time.After(time.Duration(60) * time.Second): // case <-time.After(time.Duration(60) * time.Second):
err := os.RemoveAll(task.Parent) // err := os.RemoveAll(task.Parent)
if err != nil { // if err != nil {
util.Log().Warning("无法删除离线下载临时目录[%s], %s", task.Parent, err) // util.Log().Warning("无法删除离线下载临时目录[%s], %s", task.Parent, err)
} // }
} // }
}(task) //}(task)
return err return err
} }

@ -101,6 +101,7 @@ func (monitor *Monitor) Update() bool {
case "removed": case "removed":
monitor.Task.Status = Canceled monitor.Task.Status = Canceled
monitor.Task.Save() monitor.Task.Save()
monitor.RemoveTempFolder()
return true return true
default: default:
util.Log().Warning("下载任务[%s]返回未知状态信息[%s]", monitor.Task.GID, status.Status) util.Log().Warning("下载任务[%s]返回未知状态信息[%s]", monitor.Task.GID, status.Status)

@ -40,7 +40,6 @@ type group struct {
Name string `json:"name"` Name string `json:"name"`
AllowShare bool `json:"allowShare"` AllowShare bool `json:"allowShare"`
AllowRemoteDownload bool `json:"allowRemoteDownload"` AllowRemoteDownload bool `json:"allowRemoteDownload"`
AllowTorrentDownload bool `json:"allowTorrentDownload"`
AllowArchiveDownload bool `json:"allowArchiveDownload"` AllowArchiveDownload bool `json:"allowArchiveDownload"`
ShareFreeEnabled bool `json:"shareFree"` ShareFreeEnabled bool `json:"shareFree"`
ShareDownload bool `json:"shareDownload"` ShareDownload bool `json:"shareDownload"`

Loading…
Cancel
Save