MCPcopy Index your code
hub / github.com/dnote/dnote / InitDnoteDirs

Function InitDnoteDirs

pkg/cli/context/files.go:27–48  ·  view source on GitHub ↗

InitDnoteDirs creates the dnote directories if they don't already exist.

(paths Paths)

Source from the content-addressed store, hash-verified

25
26// InitDnoteDirs creates the dnote directories if they don't already exist.
27func InitDnoteDirs(paths Paths) error {
28 if paths.Config != "" {
29 configDir := filepath.Join(paths.Config, consts.DnoteDirName)
30 if err := utils.EnsureDir(configDir); err != nil {
31 return errors.Wrap(err, "initializing config dir")
32 }
33 }
34 if paths.Data != "" {
35 dataDir := filepath.Join(paths.Data, consts.DnoteDirName)
36 if err := utils.EnsureDir(dataDir); err != nil {
37 return errors.Wrap(err, "initializing data dir")
38 }
39 }
40 if paths.Cache != "" {
41 cacheDir := filepath.Join(paths.Cache, consts.DnoteDirName)
42 if err := utils.EnsureDir(cacheDir); err != nil {
43 return errors.Wrap(err, "initializing cache dir")
44 }
45 }
46
47 return nil
48}

Callers 5

initFilesFunction · 0.92
TestInitDnoteDirsFunction · 0.85
InitTestCtxFunction · 0.85
InitTestCtxWithDBFunction · 0.85
InitTestCtxWithFileDBFunction · 0.85

Calls 1

EnsureDirFunction · 0.92

Tested by 1

TestInitDnoteDirsFunction · 0.68