From f8d538b0f174711f3c44f4a65719053119614d4d Mon Sep 17 00:00:00 2001 From: Gaius Date: Thu, 7 Dec 2023 20:48:30 +0800 Subject: [PATCH] feat: dfget sets data dir and cache dir (#2931) feat: dfget sets data and cache dir Signed-off-by: Gaius --- client/config/dfget.go | 6 ++++++ cmd/dfget/cmd/root.go | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/client/config/dfget.go b/client/config/dfget.go index 67ab0becadd..cd9a026d2e8 100644 --- a/client/config/dfget.go +++ b/client/config/dfget.go @@ -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"` diff --git a/cmd/dfget/cmd/root.go b/cmd/dfget/cmd/root.go index e411f3ee993..e48e9bc64e6 100644 --- a/cmd/dfget/cmd/root.go +++ b/cmd/dfget/cmd/root.go @@ -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") @@ -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)) }