diff --git a/Makefile b/Makefile index 0ef173d3..f4ddd56d 100644 --- a/Makefile +++ b/Makefile @@ -102,7 +102,8 @@ run: -thumbnailVideoURL "https://vith.vibioh.fr" \ -exifURL "http://localhost:4000" \ -exifGeocodeURL "https://nominatim.openstreetmap.org" \ - -exifDateOnStart + -exifDateOnStart \ + -aggregateExifOnStart .PHONY: run-imaginary run-imaginary: diff --git a/README.md b/README.md index b6bf4fb9..909d13ed 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,8 @@ You'll find a Kubernetes exemple in the [`infra/`](infra/) folder, using my [`ap Usage of fibr: -address string [server] Listen address {FIBR_ADDRESS} + -aggregateExifOnStart + [crud] Aggregate EXIF data per folder on start {FIBR_AGGREGATE_EXIF_ON_START} -authProfiles string [auth] Users profiles in the form 'id:profile1|profile2,id2:profile1' {FIBR_AUTH_PROFILES} -authUsers string diff --git a/pkg/exif/util.go b/pkg/exif/util.go index 0a214f51..773a96d3 100644 --- a/pkg/exif/util.go +++ b/pkg/exif/util.go @@ -83,7 +83,20 @@ func (a app) loadMetadata(item provider.StorageItem, suffix string, content inte } func (a app) saveMetadata(item provider.StorageItem, suffix string, data interface{}) error { - writer, err := a.storageApp.WriterTo(getExifPath(item, suffix)) + filename := getExifPath(item, suffix) + dirname := path.Dir(filename) + + if _, err := a.storageApp.Info(dirname); err != nil { + if !provider.IsNotExist(err) { + return fmt.Errorf("unable to check directory existence: %s", err) + } + + if err = a.storageApp.CreateDir(dirname); err != nil { + return fmt.Errorf("unable to create directory: %s", err) + } + } + + writer, err := a.storageApp.WriterTo(filename) if err != nil { return fmt.Errorf("unable to get writer: %s", err) }