From 0d2ac10af82b1233a59ec27e8f30559f3cc8476b Mon Sep 17 00:00:00 2001 From: liwei Date: Fri, 10 Feb 2023 21:40:16 +0800 Subject: [PATCH] fix: rename logic --- pkg/download/downloader.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/download/downloader.go b/pkg/download/downloader.go index daf326b0..7d11f776 100644 --- a/pkg/download/downloader.go +++ b/pkg/download/downloader.go @@ -228,20 +228,20 @@ func (d *Downloader) Create(rrId string, opts *base.Options) (taskId string, err // check if the download file is duplicated and rename it automatically. files := res.Files - if len(files) == 1 { - fullPath := meta.Filepath(files[0]) - newName, err := util.CheckDuplicateAndRename(fullPath) - if err != nil { - return "", err - } - opts.Name = newName - } else if res.RootDir != "" { + if res.RootDir != "" { fullDirPath := path.Join(opts.Path, res.RootDir) newName, err := util.CheckDuplicateAndRename(fullDirPath) if err != nil { return "", err } res.RootDir = newName + } else if len(files) == 1 { + fullPath := meta.Filepath(files[0]) + newName, err := util.CheckDuplicateAndRename(fullPath) + if err != nil { + return "", err + } + opts.Name = newName } err = fetcher.Create(opts)