From ad97c2f3222dcdb8c124747feb4564ca9069fa1e Mon Sep 17 00:00:00 2001 From: RanXom Date: Tue, 14 Jul 2026 10:57:01 +0530 Subject: refactor(service): synchronize gallery access --- internal/service/reload.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'internal/service/reload.go') diff --git a/internal/service/reload.go b/internal/service/reload.go index 98e4710..9460dbc 100644 --- a/internal/service/reload.go +++ b/internal/service/reload.go @@ -6,7 +6,7 @@ import ( "github.com/RanXom/galleryd/internal/gallery" ) -// Load scans the configured roots and rebuilds the in-memory gallery. +// Reload 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 { @@ -27,7 +27,9 @@ func (s *galleryService) Reload(ctx context.Context) error { index.byID[photo.ID] = photo } + s.mu.Lock() s.index = index + s.mu.Unlock() return nil } -- cgit v1.2.3