/
githubmirror
/
photoprism
Обзор
Документация
Войти
/
githubmirror
/
photoprism
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
pkg/fs/cache.go
27 строк
633 B
Michael Mayer
Config: Show error if originals and storage path seem identical #1642
21 янв 2024, 16:22
21 янв 2024, 16:22
86dc89c
Код
Авторство
О чём код?
package fs import ( "fmt" "path" ) // CachePath returns a cache directory name based on the base path, file hash and cache namespace. func CachePath(basePath, fileHash, namespace string, create bool) (cachePath string, err error) { if len(fileHash) < 4 { return "", fmt.Errorf("cache: hash '%s' is too short", fileHash) } if namespace == "" { return "", fmt.Errorf("cache: namespace for hash '%s' is empty", fileHash) } cachePath = path.Join(basePath, namespace, fileHash[0:1], fileHash[1:2], fileHash[2:3]) if create { if err = MkdirAll(cachePath); err != nil { return "", err } } return cachePath, nil }