Skip to content

Commit

Permalink
Make OS independent filepath
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevsaddam committed Nov 3, 2021
1 parent 2033db6 commit 935fd18
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,15 @@ func (d *DownloadManager) Download(url string) *DownloadManager {
if d.option.path != "" {
d.option.log.Printf("Info: Root directory: %s\n", d.option.path)

fileName = fmt.Sprintf("%s/%s", d.option.path, d.fileName)
fileName = filepath.Join(d.option.path, d.fileName)

if !d.option.skipSubPathMap {
subPath := "other"
if sp := d.option.subPathMap.Get(filepath.Ext(d.fileName)); sp != "" {
subPath = sp
}

makeSubDir := fmt.Sprintf("%s/%s", d.option.path, subPath)
makeSubDir := filepath.Join(d.option.path, subPath)
if _, err := os.Stat(makeSubDir); os.IsNotExist(err) {
if err := os.MkdirAll(makeSubDir, os.ModePerm); err != nil {
d.option.log.Printf("Error: failed to create sub-directory: %s\n", err.Error())
Expand All @@ -283,7 +283,7 @@ func (d *DownloadManager) Download(url string) *DownloadManager {
d.option.log.Printf("Info: Created sub-directory: %s\n", subPath)
}

fileName = fmt.Sprintf("%s/%s/%s", d.option.path, subPath, d.fileName)
fileName = filepath.Join(d.option.path, subPath, d.fileName)
}
}
d.location = fileName // set location value
Expand Down

0 comments on commit 935fd18

Please sign in to comment.