Skip to content

Commit

Permalink
feat: dfget sets data dir and cache dir (#2931)
Browse files Browse the repository at this point in the history
feat: dfget sets data and cache dir

Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored Dec 7, 2023
1 parent 76530ae commit f8d538b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client/config/dfget.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ type ClientOption struct {
// LogDir is log directory of dfget.
LogDir string `yaml:"logDir,omitempty" mapstructure:"logDir,omitempty"`

// DataDir is data directory of dfget.
DataDir string `yaml:"dataDir,omitempty" mapstructure:"dataDir,omitempty"`

// CacheDir is cache directory of dfget.
CacheDir string `yaml:"cacheDir,omitempty" mapstructure:"cacheDir,omitempty"`

// WorkHome is working directory of dfget.
WorkHome string `yaml:"workHome,omitempty" mapstructure:"workHome,omitempty"`

Expand Down
12 changes: 12 additions & 0 deletions cmd/dfget/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ func init() {

flagSet.String("logdir", dfgetConfig.LogDir, "Dfget log directory")

flagSet.String("datadir", dfgetConfig.DataDir, "Dfget data directory")

flagSet.String("cachedir", dfgetConfig.CacheDir, "Dfget cache directory")

flagSet.BoolP("recursive", "r", dfgetConfig.Recursive,
"Recursively download all resources in target url, the target source client must support list action")

Expand Down Expand Up @@ -207,6 +211,14 @@ func initDfgetDfpath(cfg *config.ClientOption) (dfpath.Dfpath, error) {
options = append(options, dfpath.WithLogDir(cfg.LogDir))
}

if cfg.DataDir != "" {
options = append(options, dfpath.WithDataDir(cfg.DataDir))
}

if cfg.CacheDir != "" {
options = append(options, dfpath.WithCacheDir(cfg.CacheDir))
}

if cfg.DaemonSock != "" {
options = append(options, dfpath.WithDownloadUnixSocketPath(cfg.DaemonSock))
}
Expand Down

0 comments on commit f8d538b

Please sign in to comment.