diff --git a/Makefile b/Makefile index 7d161253e..43f524b30 100644 --- a/Makefile +++ b/Makefile @@ -102,8 +102,8 @@ test-verbose: $(info Running all Go unit tests in verbose mode...) $(GOTEST) -parallel 1 -count 1 -cpu 1 -tags slow -timeout 20m -v ./pkg/... ./internal/... test-short: - $(info Running short Go unit tests in verbose mode...) - $(GOTEST) -parallel 1 -count 1 -cpu 1 -short -timeout 5m -v ./pkg/... ./internal/... + $(info Running short Go unit tests in parallel mode...) + $(GOTEST) -parallel 2 -count 1 -cpu 2 -short -timeout 5m ./pkg/... ./internal/... test-race: $(info Running all Go unit tests with race detection in verbose mode...) $(GOTEST) -tags slow -race -timeout 60m -v ./pkg/... ./internal/... diff --git a/internal/api/photo.go b/internal/api/photo.go index 0b023fd7a..289cc3867 100644 --- a/internal/api/photo.go +++ b/internal/api/photo.go @@ -76,6 +76,8 @@ func UpdatePhoto(router *gin.RouterGroup, conf *config.Config) { return } + log.Info("photo: updating related entity counts") + if err := query.UpdatePhotoCounts(); err != nil { log.Errorf("photo: %s", err) } diff --git a/internal/api/photo_label.go b/internal/api/photo_label.go index d52ec47d3..1fd9197b4 100644 --- a/internal/api/photo_label.go +++ b/internal/api/photo_label.go @@ -71,6 +71,8 @@ func AddPhotoLabel(router *gin.RouterGroup, conf *config.Config) { return } + log.Info("photo: updating related entity counts") + if err := query.UpdatePhotoCounts(); err != nil { log.Errorf("photo: %s", err) } @@ -135,6 +137,8 @@ func RemovePhotoLabel(router *gin.RouterGroup, conf *config.Config) { return } + log.Info("photo: updating related entity counts") + if err := query.UpdatePhotoCounts(); err != nil { log.Errorf("photo: %s", err) } diff --git a/internal/photoprism/import.go b/internal/photoprism/import.go index 4e2749d09..041740ead 100644 --- a/internal/photoprism/import.go +++ b/internal/photoprism/import.go @@ -195,8 +195,12 @@ func (imp *Import) Start(opt ImportOptions) map[string]bool { log.Error(err.Error()) } - if err := query.UpdatePhotoCounts(); err != nil { - log.Errorf("import: %s", err) + if len(done) > 0 { + log.Info("import: updating photo counts") + + if err := query.UpdatePhotoCounts(); err != nil { + log.Errorf("import: %s", err) + } } runtime.GC() diff --git a/internal/photoprism/index.go b/internal/photoprism/index.go index e8b3fcb0a..1caccc657 100644 --- a/internal/photoprism/index.go +++ b/internal/photoprism/index.go @@ -171,8 +171,12 @@ func (ind *Index) Start(opt IndexOptions) map[string]bool { log.Error(err.Error()) } - if err := query.UpdatePhotoCounts(); err != nil { - log.Errorf("index: %s", err) + if len(done) > 0 { + log.Info("index: updating photo counts") + + if err := query.UpdatePhotoCounts(); err != nil { + log.Errorf("index: %s", err) + } } runtime.GC() diff --git a/internal/photoprism/purge.go b/internal/photoprism/purge.go index aa3c2092a..0459c854c 100644 --- a/internal/photoprism/purge.go +++ b/internal/photoprism/purge.go @@ -175,7 +175,7 @@ func (prg *Purge) Start(opt PurgeOptions) (purgedFiles map[string]bool, purgedPh log.Info("purge: updating photo counts") if err := query.UpdatePhotoCounts(); err != nil { - return purgedFiles, purgedPhotos, err + log.Errorf("purge: %s", err) } return purgedFiles, purgedPhotos, nil diff --git a/internal/workers/sync_download.go b/internal/workers/sync_download.go index 175314bd9..13c2f2b18 100644 --- a/internal/workers/sync_download.go +++ b/internal/workers/sync_download.go @@ -179,5 +179,13 @@ func (s *Sync) download(a entity.Account) (complete bool, err error) { } } + if len(done) > 0 { + log.Info("sync: updating photo counts") + + if err := query.UpdatePhotoCounts(); err != nil { + log.Errorf("sync: %s", err) + } + } + return false, nil }