pkg/index: on slurping bogus gps coordinate, log instead of panicking

If a GPS coordinate is bogus, we should have caught it when receiving
the blob, and not write it out as an index row.
If we did not, we end up catching it when trying to slurp it to the
corpus. At this point there's no reason to penalize the user by
panicking, we can instead skip it and log about the error.

Change-Id: Ie40479befca78d8b5da343ef1a8420f703f07cb7
This commit is contained in:
mpl 2018-04-24 17:45:13 -07:00
parent 66e6766571
commit 1aeadf4a8a
1 changed files with 6 additions and 1 deletions

View File

@ -845,7 +845,12 @@ func (c *Corpus) mergeEXIFGPSRow(k, v []byte) error {
lat, err := strconv.ParseFloat(string(v[:pipe]), 64)
long, err1 := strconv.ParseFloat(string(v[pipe+1:]), 64)
if err != nil || err1 != nil {
return fmt.Errorf("bogus row %q = %q", k, v)
if err != nil {
log.Printf("index: bogus latitude in value of row %q = %q", k, v)
} else {
log.Printf("index: bogus longitude in value of row %q = %q", k, v)
}
return nil
}
c.gps[wholeRef] = latLong{lat, long}
return nil