mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
24 lines
602 B
Go
24 lines
602 B
Go
package download
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/photoprism/photoprism/pkg/clean"
|
|
"github.com/photoprism/photoprism/pkg/rnd"
|
|
)
|
|
|
|
// Find returns the fileName for the given download id or an error if the id is invalid.
|
|
func Find(uniqueId string) (fileName string, err error) {
|
|
if uniqueId == "" || !rnd.IsUUID(uniqueId) {
|
|
return fileName, fmt.Errorf("id has an invalid format")
|
|
}
|
|
|
|
// Cached?
|
|
if cacheData, hit := cache.Get(uniqueId); hit {
|
|
log.Tracef("download: cache hit for %s", uniqueId)
|
|
return cacheData.(string), nil
|
|
}
|
|
|
|
return "", fmt.Errorf("invalid id %s", clean.LogQuote(uniqueId))
|
|
}
|