diff options
| author | Saiyed Shizain <saiyedshizain@gmail.com> | 2026-07-13 12:53:53 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-13 12:53:53 +0530 |
| commit | ed70370d9f58d39c3b31f5506e449aeb5d562a77 (patch) | |
| tree | 58563adfc17bfba97b80e480d356219f63d6700c /internal/gallery/id.go | |
| parent | 1a3e963e88a76e3bf9bdab74b251331a7edfe5cb (diff) | |
| parent | f2ec755fa94c61f18873b3b9feab43eb234d2d82 (diff) | |
| download | galleryd-ed70370d9f58d39c3b31f5506e449aeb5d562a77.tar.xz galleryd-ed70370d9f58d39c3b31f5506e449aeb5d562a77.zip | |
Merge pull request #4 from RanXom/feat/gallery
Feat/gallery: implement gallery domain model
Diffstat (limited to 'internal/gallery/id.go')
| -rw-r--r-- | internal/gallery/id.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/gallery/id.go b/internal/gallery/id.go new file mode 100644 index 0000000..edb5be2 --- /dev/null +++ b/internal/gallery/id.go @@ -0,0 +1,21 @@ +package gallery + +import ( + "crypto/sha256" + "encoding/hex" + "path/filepath" + + "github.com/RanXom/galleryd/internal/scanner" +) + +// generateID returns a deterministic identifier for a photo. +// +// IDs are generated from the cleaned root and relative path to avoid +// collisions when multiple roots contain the same directory layout. +func generateID(file scanner.File) string { + canonical := filepath.Join(file.Root, file.RelativePath) + + sum := sha256.Sum256([]byte(canonical)) + + return hex.EncodeToString(sum[:]) +} |