MCPcopy Create free account
hub / github.com/bufbuild/buf / createCacheDir

Function createCacheDir

private/buf/bufcli/cache.go:370–399  ·  view source on GitHub ↗
(baseCacheDirPath string, relDirPath string)

Source from the content-addressed store, hash-verified

368}
369
370func createCacheDir(baseCacheDirPath string, relDirPath string) error {
371 baseCacheDirPath = normalpath.Unnormalize(baseCacheDirPath)
372 relDirPath = normalpath.Unnormalize(relDirPath)
373 fullDirPath := filepath.Join(baseCacheDirPath, relDirPath)
374 // OK to use os.Stat instead of os.LStat here as this is CLI-only
375 fileInfo, err := os.Stat(fullDirPath)
376 if err != nil {
377 if errors.Is(err, fs.ErrNotExist) {
378 return os.MkdirAll(fullDirPath, 0755)
379 }
380 return err
381 }
382 if !fileInfo.IsDir() {
383 return fmt.Errorf(
384 "Expected %q to be a directory. This is used for buf's cache. "+
385 "You can override the base cache directory %q by setting the $BUF_CACHE_DIR environment variable.",
386 fullDirPath,
387 baseCacheDirPath,
388 )
389 }
390 if fileInfo.Mode().Perm()&0700 != 0700 {
391 return fmt.Errorf(
392 "Expected %q to be a writeable directory. This is used for buf's cache. "+
393 "You can override the base cache directory %q by setting the $BUF_CACHE_DIR environment variable.",
394 fullDirPath,
395 baseCacheDirPath,
396 )
397 }
398 return nil
399}

Callers 6

NewWasmRuntimeFunction · 0.85
NewWKTStoreFunction · 0.85
newModuleDataProviderFunction · 0.85
newCommitProviderFunction · 0.85
newPluginDataProviderFunction · 0.85
newPolicyDataProviderFunction · 0.85

Calls 2

UnnormalizeFunction · 0.92
StatMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…