diff options
author | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-06-23 21:25:37 +0200 |
---|---|---|
committer | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-06-23 21:25:37 +0200 |
commit | 1dea35b9bcb3d37d61e554a99488626da9795331 (patch) | |
tree | c8d7cea6e3b44121e067edebf91f2044f8538b6b /pkg | |
parent | 8eeddc0bfb574aada6bb76638957421b52344bb0 (diff) | |
download | lens-1dea35b9bcb3d37d61e554a99488626da9795331.tar.gz lens-1dea35b9bcb3d37d61e554a99488626da9795331.tar.bz2 lens-1dea35b9bcb3d37d61e554a99488626da9795331.zip |
feat: Remove unecessary param from repo
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/database/sql/media.go | 2 | ||||
-rw-r--r-- | pkg/worker/exif_scanner.go | 2 | ||||
-rw-r--r-- | pkg/worker/file_scanner.go | 6 | ||||
-rw-r--r-- | pkg/worker/list_processor_test.go | 2 | ||||
-rw-r--r-- | pkg/worker/worker.go | 4 |
5 files changed, 11 insertions, 5 deletions
diff --git a/pkg/database/sql/media.go b/pkg/database/sql/media.go index 835e262..59a4b83 100644 --- a/pkg/database/sql/media.go +++ b/pkg/database/sql/media.go @@ -223,7 +223,7 @@ func (r *MediaRepository) GetEmptyEXIF(ctx context.Context, pagination *media.Pa Where("media_exifs.media_id IS NULL"). Offset(pagination.Page * pagination.Size). Limit(pagination.Size). - Order("created_at DESC"). + Order("media.created_at DESC"). Find(&medias) if result.Error != nil { diff --git a/pkg/worker/exif_scanner.go b/pkg/worker/exif_scanner.go index 66091cd..6d40dbd 100644 --- a/pkg/worker/exif_scanner.go +++ b/pkg/worker/exif_scanner.go @@ -15,7 +15,7 @@ type ( var _ ListProcessor[*media.Media] = &EXIFScanner{} -func NewEXIFScanner(root string, repository media.Repository) *EXIFScanner { +func NewEXIFScanner(repository media.Repository) *EXIFScanner { return &EXIFScanner{ repository: repository, } diff --git a/pkg/worker/file_scanner.go b/pkg/worker/file_scanner.go index 321fbca..0dc2eb2 100644 --- a/pkg/worker/file_scanner.go +++ b/pkg/worker/file_scanner.go @@ -33,6 +33,12 @@ func (f *FileScanner) Query(ctx context.Context) (<-chan string, error) { go func() { defer close(c) _ = filepath.Walk(f.root, func(path string, info fs.FileInfo, err error) error { + select { + case <-ctx.Done(): + return filepath.SkipAll + default: + } + if info.IsDir() && filepath.Base(info.Name())[0] == '.' { return filepath.SkipDir } diff --git a/pkg/worker/list_processor_test.go b/pkg/worker/list_processor_test.go index b7373d1..1e4ed2d 100644 --- a/pkg/worker/list_processor_test.go +++ b/pkg/worker/list_processor_test.go @@ -1,4 +1,4 @@ -// go:build unit +//go:build unit package worker diff --git a/pkg/worker/worker.go b/pkg/worker/worker.go index c52f0be..18cc0e2 100644 --- a/pkg/worker/worker.go +++ b/pkg/worker/worker.go @@ -36,12 +36,12 @@ func (self *WorkerPool) AddWorker(name string, worker Worker) { } func (self *WorkerPool) Start(ctx context.Context) { + self.wg.Add(len(self.workers)) for _, w := range self.workers { - self.wg.Add(1) go func(w *Work) { defer self.wg.Done() if err := w.Worker.Start(ctx); err != nil && !errors.Is(err, context.Canceled) { - fmt.Println("Error ", w.Name, err.Error()) + fmt.Println("Processes finished, error", w.Name, err.Error()) } else { fmt.Println(w.Name, "done") } |