From 635f00ac71831e29ebd2893b7ea4f34ec0b0a866 Mon Sep 17 00:00:00 2001 From: krau <71133316+krau@users.noreply.github.com> Date: Fri, 21 Mar 2025 23:28:14 +0800 Subject: [PATCH] fix: reorganize cache destination path handling in processPendingTask function --- core/download.go | 17 +++++++++-------- go.mod | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/core/download.go b/core/download.go index 56802b4..36b6e08 100644 --- a/core/download.go +++ b/core/download.go @@ -23,14 +23,6 @@ func processPendingTask(task *types.Task) error { if task.FileName() == "" { task.File.FileName = fmt.Sprintf("%d_%d_%s", task.FileChatID, task.FileMessageID, task.File.Hash()) } - cacheDestPath := filepath.Join(config.Cfg.Temp.BasePath, task.FileName()) - cacheDestPath, err := filepath.Abs(cacheDestPath) - if err != nil { - return fmt.Errorf("处理路径失败: %w", err) - } - if err := fileutil.CreateDir(filepath.Dir(cacheDestPath)); err != nil { - return fmt.Errorf("创建目录失败: %w", err) - } if task.StoragePath == "" { task.StoragePath = task.File.FileName @@ -93,6 +85,15 @@ func processPendingTask(task *types.Task) error { return nil } + cacheDestPath := filepath.Join(config.Cfg.Temp.BasePath, task.FileName()) + cacheDestPath, err = filepath.Abs(cacheDestPath) + if err != nil { + return fmt.Errorf("处理路径失败: %w", err) + } + if err := fileutil.CreateDir(filepath.Dir(cacheDestPath)); err != nil { + return fmt.Errorf("创建目录失败: %w", err) + } + text, entities := buildProgressMessageEntity(task, 0, task.StartTime, 0) ctx.EditMessage(task.ReplyChatID, &tg.MessagesEditMessageRequest{ Message: text, diff --git a/go.mod b/go.mod index cb22f44..c1affaa 100644 --- a/go.mod +++ b/go.mod @@ -97,7 +97,7 @@ require ( github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac // indirect - golang.org/x/sync v0.12.0 // indirect + golang.org/x/sync v0.12.0 golang.org/x/sys v0.31.0 // indirect golang.org/x/text v0.23.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect