aboutsummaryrefslogtreecommitdiff
path: root/internal/thumbnail/cache.go
diff options
context:
space:
mode:
authorRanXom <saiyedshizain@gmail.com>2026-07-13 13:05:50 +0530
committerRanXom <saiyedshizain@gmail.com>2026-07-13 13:05:50 +0530
commit8fd991a5a618e4dd0086669d682ead22d99a3a6e (patch)
tree608a30f9edc91284480f3332d9e7c2f3b7302d4f /internal/thumbnail/cache.go
parent561ab3a87a7d6880c994abfdfcbc94780d54f843 (diff)
downloadgalleryd-8fd991a5a618e4dd0086669d682ead22d99a3a6e.tar.xz
galleryd-8fd991a5a618e4dd0086669d682ead22d99a3a6e.zip
feat(thumbnail): define thumbnail cache layout
Diffstat (limited to 'internal/thumbnail/cache.go')
-rw-r--r--internal/thumbnail/cache.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/thumbnail/cache.go b/internal/thumbnail/cache.go
new file mode 100644
index 0000000..38f5d07
--- /dev/null
+++ b/internal/thumbnail/cache.go
@@ -0,0 +1,28 @@
+package thumbnail
+
+import (
+ "path/filepath"
+
+ "github.com/RanXom/galleryd/internal/gallery"
+)
+
+const (
+ 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",
+ shard,
+ filename,
+ )
+}