Skip to content

Commit

Permalink
better errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kmulvey committed Dec 7, 2022
1 parent 735c3bc commit 1a7face
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/app/imagedup/hash/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package hash

import (
"encoding/json"
"errors"
"fmt"
"image"
"image/jpeg"
Expand Down Expand Up @@ -81,7 +82,11 @@ func NewCache(file, globPattern, promNamespace string, numFiles int) (*Cache, er
}

for i, hash := range m.Hashes {
c.store[i] = &Image{goimagehash.NewImageHash(hash, goimagehash.PHash), image.Config{}}
if i < len(c.store) {
c.store[i] = &Image{goimagehash.NewImageHash(hash, goimagehash.PHash), image.Config{}}
} else {
return nil, errors.New(fmt.Sprintf("number of hases: %d, does not match store size: %d, delete the cache file: %s", len(m.Hashes), numFiles, file))
}
}
}

Expand Down

0 comments on commit 1a7face

Please sign in to comment.