Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dfget sets data dir and cache dir #2931

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading