2026-07-18 04:55:33 +00:00
|
|
|
package config
|
2026-07-18 00:07:53 +00:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
)
|
|
|
|
|
|
2026-11-21 22:49:41 +00:00
|
|
|
func DefaultCacheRoot(userCacheDir func() (string, error)) (string, error) {
|
2026-07-18 00:07:53 +00:00
|
|
|
if userCacheDir == nil {
|
|
|
|
|
return "", fmt.Errorf("user cache directory resolver must not be nil")
|
|
|
|
|
}
|
|
|
|
|
root, err := userCacheDir()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", fmt.Errorf("resolve user cache directory: %w", err)
|
|
|
|
|
}
|
|
|
|
|
if root == "" {
|
|
|
|
|
return "", fmt.Errorf("user cache directory must not be empty")
|
|
|
|
|
}
|
2026-11-21 22:49:41 +00:00
|
|
|
return filepath.Join(root, "notarius"), nil
|
2026-07-18 00:07:53 +00:00
|
|
|
}
|