feat: optimize dfpath format (#2460)
Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
parent
8c905d9b8d
commit
8b7ceb60b5
|
|
@ -103,6 +103,7 @@ func initDaemonDfpath(cfg *config.DaemonOption) (dfpath.Dfpath, error) {
|
||||||
if cfg.WorkHome != "" {
|
if cfg.WorkHome != "" {
|
||||||
options = append(options, dfpath.WithWorkHome(cfg.WorkHome))
|
options = append(options, dfpath.WithWorkHome(cfg.WorkHome))
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.FileMode(cfg.WorkHomeMode) != os.FileMode(0) {
|
if os.FileMode(cfg.WorkHomeMode) != os.FileMode(0) {
|
||||||
options = append(options, dfpath.WithWorkHomeMode(os.FileMode(cfg.WorkHomeMode)))
|
options = append(options, dfpath.WithWorkHomeMode(os.FileMode(cfg.WorkHomeMode)))
|
||||||
}
|
}
|
||||||
|
|
@ -110,6 +111,7 @@ func initDaemonDfpath(cfg *config.DaemonOption) (dfpath.Dfpath, error) {
|
||||||
if cfg.CacheDir != "" {
|
if cfg.CacheDir != "" {
|
||||||
options = append(options, dfpath.WithCacheDir(cfg.CacheDir))
|
options = append(options, dfpath.WithCacheDir(cfg.CacheDir))
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.FileMode(cfg.CacheDirMode) != os.FileMode(0) {
|
if os.FileMode(cfg.CacheDirMode) != os.FileMode(0) {
|
||||||
options = append(options, dfpath.WithCacheDirMode(os.FileMode(cfg.CacheDirMode)))
|
options = append(options, dfpath.WithCacheDirMode(os.FileMode(cfg.CacheDirMode)))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
package dfpath
|
package dfpath
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"d7y.io/dragonfly/v2/pkg/os/user"
|
"d7y.io/dragonfly/v2/pkg/os/user"
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ func TestNew(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "new dfpath by workHome",
|
name: "new dfpath by workHome and workHomeMode",
|
||||||
options: []Option{WithWorkHome("foo"), WithWorkHomeMode(os.FileMode(0700))},
|
options: []Option{WithWorkHome("foo"), WithWorkHomeMode(os.FileMode(0700))},
|
||||||
expect: func(t *testing.T, options []Option) {
|
expect: func(t *testing.T, options []Option) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
@ -77,7 +77,7 @@ func TestNew(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "new dfpath by cacheDir",
|
name: "new dfpath by cacheDir and cacheDirMode",
|
||||||
options: []Option{WithCacheDir("foo"), WithCacheDirMode(os.FileMode(0700))},
|
options: []Option{WithCacheDir("foo"), WithCacheDirMode(os.FileMode(0700))},
|
||||||
expect: func(t *testing.T, options []Option) {
|
expect: func(t *testing.T, options []Option) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
@ -113,7 +113,7 @@ func TestNew(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "new dfpath by dataDir",
|
name: "new dfpath by dataDir and dataDirMode",
|
||||||
options: []Option{WithDataDir("foo"), WithDataDirMode(os.FileMode(0700))},
|
options: []Option{WithDataDir("foo"), WithDataDirMode(os.FileMode(0700))},
|
||||||
expect: func(t *testing.T, options []Option) {
|
expect: func(t *testing.T, options []Option) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue