mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-18 22:33:42 +00:00
fix: rename logic
This commit is contained in:
1 parent
978b8bc7cb
commit
0d2ac10af8
1 file changed
+8
-8
@@ -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.
|
// check if the download file is duplicated and rename it automatically.
|
||||||
files := res.Files
|
files := res.Files
|
||||||
if len(files) == 1 {
|
if res.RootDir != "" {
|
||||||
fullPath := meta.Filepath(files[0])
|
|
||||||
newName, err := util.CheckDuplicateAndRename(fullPath)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
opts.Name = newName
|
|
||||||
} else if res.RootDir != "" {
|
|
||||||
fullDirPath := path.Join(opts.Path, res.RootDir)
|
fullDirPath := path.Join(opts.Path, res.RootDir)
|
||||||
newName, err := util.CheckDuplicateAndRename(fullDirPath)
|
newName, err := util.CheckDuplicateAndRename(fullDirPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
res.RootDir = newName
|
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)
|
err = fetcher.Create(opts)
|
||||||
|
|||||||
Reference in new issue
Block a user