MCPcopy
hub / github.com/perkeep/perkeep / CamliVarDir

Function CamliVarDir

internal/osutil/paths.go:100–117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

98}
99
100func CamliVarDir() (string, error) {
101 oldName := camliVarDirOf("camlistore")
102 newName := camliVarDirOf("perkeep")
103
104 if fi, err := os.Lstat(oldName); err == nil && fi.IsDir() && oldName != newName {
105 n, err := numRegularFilesUnder(oldName)
106 if err != nil {
107 return "", fmt.Errorf("error enumerating old directory %s: %w", oldName, err)
108 }
109 if n == 0 {
110 log.Printf("removing old, empty var directory %s", oldName)
111 os.RemoveAll(oldName)
112 } else {
113 return "", fmt.Errorf("Now that Perkeep has been renamed from Camlistore, you need to rename your data directory from %s to %s", oldName, newName)
114 }
115 }
116 return newName, nil
117}
118
119func numRegularFilesUnder(dir string) (n int, err error) {
120 err = filepath.Walk(dir, func(path string, fi os.FileInfo, err error) error {

Callers 2

WriteDefaultConfigFileFunction · 0.92
CamliBlobRootFunction · 0.85

Calls 5

camliVarDirOfFunction · 0.85
numRegularFilesUnderFunction · 0.85
PrintfMethod · 0.80
LstatMethod · 0.65
IsDirMethod · 0.65

Tested by

no test coverage detected