blob: 9460dbc0dbfd8db566e53df473305bc7d335c44d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package service
import (
"context"
"github.com/RanXom/galleryd/internal/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 {
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.mu.Lock()
s.index = index
s.mu.Unlock()
return nil
}
|