aboutsummaryrefslogtreecommitdiff
path: root/internal/service/reload.go
diff options
context:
space:
mode:
authorRanXom <saiyedshizain@gmail.com>2026-07-14 10:45:04 +0530
committerRanXom <saiyedshizain@gmail.com>2026-07-14 10:45:04 +0530
commit826434a8597122847f643abe835d5c6e5dd74c4c (patch)
treed07d21bc30d5068e6c1e828a3e42747a8411571e /internal/service/reload.go
parentbcfb199ac8e5399e1a92cfbbc28af3674f80959d (diff)
downloadgalleryd-826434a8597122847f643abe835d5c6e5dd74c4c.tar.xz
galleryd-826434a8597122847f643abe835d5c6e5dd74c4c.zip
refactor(service): rename load to reload
Diffstat (limited to 'internal/service/reload.go')
-rw-r--r--internal/service/reload.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/internal/service/reload.go b/internal/service/reload.go
new file mode 100644
index 0000000..98e4710
--- /dev/null
+++ b/internal/service/reload.go
@@ -0,0 +1,33 @@
+package service
+
+import (
+ "context"
+
+ "github.com/RanXom/galleryd/internal/gallery"
+)
+
+// Load scans the configured roots and rebuilds the in-memory gallery.
+func (s *galleryService) Reload(ctx context.Context) error {
+ files, err := s.scanner.Scan(ctx)
+ if err != nil {
+ return err
+ }
+
+ photos, err := s.builder.Build(ctx, files)
+ if err != nil {
+ return err
+ }
+
+ index := galleryIndex{
+ photos: photos,
+ byID: make(map[string]gallery.Photo, len(photos)),
+ }
+
+ for _, photo := range photos {
+ index.byID[photo.ID] = photo
+ }
+
+ s.index = index
+
+ return nil
+}