Skip to content

Commit

Permalink
fix(exif): Creating directory is not exist
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Aug 4, 2021
1 parent 80bb0e3 commit d04785d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion pkg/exif/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit d04785d

Please sign in to comment.