Skip to content

Commit

Permalink
fix(exif): Fixing start routine not taking in account photo with desc…
Browse files Browse the repository at this point in the history
…ription

Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Aug 8, 2022
1 parent b8c9acf commit 7ce718f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 4 additions & 1 deletion pkg/exif/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
exas "github.com/ViBiOh/exas/pkg/model"
"github.com/ViBiOh/fibr/pkg/provider"
"github.com/ViBiOh/httputils/v4/pkg/cache"
"github.com/ViBiOh/httputils/v4/pkg/sha"
"github.com/ViBiOh/httputils/v4/pkg/tracer"
)

Expand All @@ -17,10 +18,12 @@ var (
aggregateRatio = 0.4

levels = []string{"city", "state", "country"}

cacheVersion = sha.New("vibioh/fibr/1")[:8]
)

func redisKey(itemID string) string {
return "fibr:exif:" + itemID
return fmt.Sprintf("fibr:%s:exif:%s", cacheVersion, itemID)
}

// GetExifFor return exif value for a given item
Expand Down
13 changes: 11 additions & 2 deletions pkg/exif/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,17 @@ func Path(item absto.Item) string {
}

func (a App) hasMetadata(ctx context.Context, item absto.Item) bool {
_, err := a.storageApp.Info(ctx, Path(item))
return err == nil
if item.IsDir {
_, err := a.storageApp.Info(ctx, Path(item))
return err == nil
}

data, err := a.loadExif(ctx, item)
if err != nil {
return false
}

return len(data.Data) != 0
}

func (a App) loadExif(ctx context.Context, item absto.Item) (exas.Exif, error) {
Expand Down

0 comments on commit 7ce718f

Please sign in to comment.