aboutsummaryrefslogtreecommitdiff
path: root/internal/service/gallery_service.go
blob: d8c2d8fb107a3d9063686bda6fc8786c990a1cf3 (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
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 s.index.photos, nil
}