package thumbnail import ( "path/filepath" "github.com/RanXom/galleryd/internal/gallery" ) const ( thumbnailVersion = "v1" thumbnailExtension = ".webp" ) // cachePath returns the on-disk cache location for a photo thumbnail. // // Thumbnails are sharded by the first two characters of the photo ID to // avoid placing large numbers of files in a single directory. func (g *Generator) cachePath(photo gallery.Photo) string { shard := photo.ID[:2] filename := photo.ID + thumbnailExtension return filepath.Join( g.cacheDir, "thumbs", thumbnailVersion, shard, filename, ) }