mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-06 00:25:43 +00:00
27 lines
580 B
Go
27 lines
580 B
Go
package download
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/GopeedLab/gopeed/internal/tempfiles"
|
|
)
|
|
|
|
// TempDir may be shared with the OS or other applications. Initialization never
|
|
// removes its contents; shutdown only removes paths created by this downloader.
|
|
func (d *Downloader) setupTempDir() error {
|
|
if d.cfg.TempDir == "" {
|
|
d.cfg.TempDir = os.TempDir()
|
|
}
|
|
root, err := filepath.Abs(d.cfg.TempDir)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := os.MkdirAll(root, 0700); err != nil {
|
|
return err
|
|
}
|
|
d.cfg.TempDir = root
|
|
d.tempFiles = &tempfiles.Scope{}
|
|
return nil
|
|
}
|