blob: 89d565246c44e073fa55fa66337426cde4afcc4b (
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
|
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, query gallery.Query) ([]gallery.Photo, error) {
_ = query
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 gallery.QueryPhotos(
s.index.photos,
query,
), nil
}
|