blob: 23a8e851df07bdff31826096af2bc30ac191b2f6 (
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
|
package service
import (
"context"
"errors"
"github.com/RanXom/galleryd/internal/gallery"
)
// Gallery scans the configured roots and builds the gallery.
func (s *galleryService) Gallery(ctx context.Context) ([]gallery.Photo, error) {
s.mu.RLock()
defer s.mu.RUnlock()
select {
case <-ctx.Done():
return nil, ctx.Err()
default:
}
if s.index.byID == nil {
return nil, errors.New("gallery not loaded")
}
return s.index.photos, nil
}
|