diff options
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | README.md | 10 | ||||
-rw-r--r-- | cmd/server/main.go | 2 | ||||
-rw-r--r-- | golangci.yml | 7 | ||||
-rw-r--r-- | main | bin | 74600 -> 0 bytes | |||
-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 | ||||
-rw-r--r-- | scss/main.scss | 2 | ||||
-rw-r--r-- | templates/layout.html | 2 |
12 files changed, 35 insertions, 10 deletions
@@ -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 @@ -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 Binary files differdiff --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 @@ </a> </div> </nav> - <div class="container is-max-desktop"> + <div class="container"> {{block "content" .}}noop{{end}} </div> </body> |