From 1dea35b9bcb3d37d61e554a99488626da9795331 Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Fri, 23 Jun 2023 21:25:37 +0200 Subject: feat: Remove unecessary param from repo --- Makefile | 6 ++++-- README.md | 10 ++++++++++ cmd/server/main.go | 2 +- golangci.yml | 7 +++++++ main | Bin 74600 -> 0 bytes pkg/database/sql/media.go | 2 +- pkg/worker/exif_scanner.go | 2 +- pkg/worker/file_scanner.go | 6 ++++++ pkg/worker/list_processor_test.go | 2 +- pkg/worker/worker.go | 4 ++-- scss/main.scss | 2 +- templates/layout.html | 2 +- 12 files changed, 35 insertions(+), 10 deletions(-) delete mode 100644 main diff --git a/Makefile b/Makefile index 39c579c..5731808 100644 --- a/Makefile +++ b/Makefile @@ -13,9 +13,11 @@ build: run: sass $(GO_RUN) $(SERVER) \ - --log-level error \ + --db-type psql \ + --db-con "host=localhost user=gabrielgio password=diablo123 dbname=img port=5432 sslmode=disable" \ + --log-level trace \ --aes-key=6368616e676520746869732070617373 \ - --root=${HOME} \ + --root=${HOME} sass: @mkdir -p static diff --git a/README.md b/README.md index 817ba0e..9f05e5f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,13 @@ # IMG A read only file explorer with media capabilities. + +# TODO + +* Thumbnail system +* Initial setup process + * Also allow setup user config file +* Single binary output +* Better worker pool. Allow cron job and ui config +* Alpine package and demo site +* Single image viewer and show exif info (not sure how yet) diff --git a/cmd/server/main.go b/cmd/server/main.go index e9314ec..0abdc09 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -112,7 +112,7 @@ func main() { var ( serverWorker = worker.NewServerWorker(&fasthttp.Server{Handler: r.Handler}) fileScanner = worker.NewFileScanner(*root, mediaRepository) - exifScanner = worker.NewEXIFScanner(*root, mediaRepository) + exifScanner = worker.NewEXIFScanner(mediaRepository) ) pool := worker.NewWorkerPool() diff --git a/golangci.yml b/golangci.yml index 25b47fd..1ad6f9c 100644 --- a/golangci.yml +++ b/golangci.yml @@ -13,6 +13,8 @@ linters: - gci - bodyclose - makezero + - govet + - contextcheck linters-settings: gci: @@ -31,6 +33,11 @@ linters-settings: disabled: false - name: package-comments disabled: true + govet: + enable-all: true + disable: + - fieldalignment + - shadow issues: exclude-use-default: false diff --git a/main b/main deleted file mode 100644 index c2b077f..0000000 Binary files a/main and /dev/null differ 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") } diff --git a/scss/main.scss b/scss/main.scss index bf6b3d8..faad1ca 100644 --- a/scss/main.scss +++ b/scss/main.scss @@ -13,6 +13,7 @@ $panel-shadow: 0; $card-shadow: 0; $card-radius: 0; +$card-content-padding: 0; @import "bulma/sass/base/_all.sass"; @import "bulma/sass/utilities/_all.sass"; @@ -38,7 +39,6 @@ body { nav { border-bottom: 1px solid; - max-width: 1024px; margin: auto; } diff --git a/templates/layout.html b/templates/layout.html index 56d02f8..e21ec5e 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -21,7 +21,7 @@ -
+
{{block "content" .}}noop{{end}}
-- cgit v1.2.3