Skip to content

Commit

Permalink
fix: rename logic
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie committed Feb 10, 2023
1 parent 978b8bc commit 0d2ac10
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pkg/download/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0d2ac10

Please sign in to comment.