blob: 09bbc2054aab5ad4c6f0b9abd4e19e57593c50aa (
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
|
package service
import (
"context"
"github.com/RanXom/galleryd/internal/gallery"
)
// Load scans the configured roots and rebuilds the in-memory gallery.
func (s *galleryService) Load(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
}
|