package worker import ( "context" "git.sr.ht/~gabrielgio/img/pkg/components/media" "git.sr.ht/~gabrielgio/img/pkg/fileop" ) type ( EXIFScanner struct { repository media.Repository } ) var _ ListProcessor[*media.Media] = &EXIFScanner{} func NewEXIFScanner(root string, repository media.Repository) *EXIFScanner { return &EXIFScanner{ repository: repository, } } func (e *EXIFScanner) Query(ctx context.Context) ([]*media.Media, error) { medias, err := e.repository.GetEmptyEXIF(ctx, &media.Pagination{ Page: 0, Size: 100, }) if err != nil { return nil, err } return medias, nil } func (e *EXIFScanner) Process(ctx context.Context, m *media.Media) error { newExif, err := fileop.ReadExif(m.Path) if err != nil { return err } return e.repository.CreateEXIF(ctx, m.ID, newExif) }