fix: auto save block ask process

fix: mark all pending transfers canceled when app exit
This commit is contained in:
2026-02-05 15:48:59 +08:00
parent 99c71f5179
commit d9db99946d
5 changed files with 29 additions and 6 deletions

View File

@@ -9,9 +9,16 @@ import (
)
func (s *Service) SaveHistory() {
// 将 pending 状态的任务改为 canceled
transferList := s.GetTransferList()
for _, task := range transferList {
if task.Status == TransferStatusPending {
task.Status = TransferStatusCanceled
}
}
configDir := config.GetConfigDir()
historyPath := filepath.Join(configDir, "history.json")
historyJson, err := json.Marshal(s.GetTransferList())
historyJson, err := json.Marshal(transferList)
if err != nil {
return
}