fix save & saveto path error to fix issue #130

This commit is contained in:
xiaoyaofenfen 2022-08-09 20:34:22 +08:00
parent 4833c787ac
commit 43f4b23981

View File

@ -28,6 +28,7 @@ import (
"github.com/tickstep/library-go/requester/rio/speeds" "github.com/tickstep/library-go/requester/rio/speeds"
"github.com/urfave/cli" "github.com/urfave/cli"
"os" "os"
"path"
"path/filepath" "path/filepath"
"runtime" "runtime"
"time" "time"
@ -105,7 +106,9 @@ func CmdDownload() cli.Command {
saveTo string saveTo string
) )
if c.Bool("save") { if c.Bool("save") {
saveTo = "." // 使用当前工作目录
pwd, _ := os.Getwd()
saveTo = path.Clean(pwd)
} else if c.String("saveto") != "" { } else if c.String("saveto") != "" {
saveTo = filepath.Clean(c.String("saveto")) saveTo = filepath.Clean(c.String("saveto"))
} }
@ -299,7 +302,7 @@ func RunDownload(paths []string, options *DownloadOptions) {
// 设置储存的路径 // 设置储存的路径
if options.SaveTo != "" { if options.SaveTo != "" {
unit.OriginSaveRootPath = options.SaveTo unit.OriginSaveRootPath = options.SaveTo
unit.SavePath = filepath.Join(options.SaveTo, filepath.Base(paths[k])) unit.SavePath = filepath.Join(options.SaveTo, paths[k])
} else { } else {
// 使用默认的保存路径 // 使用默认的保存路径
unit.OriginSaveRootPath = GetActiveUser().GetSavePath("") unit.OriginSaveRootPath = GetActiveUser().GetSavePath("")