Index: Resolve S2 cell in XMP branch, downgrade geocoding warn

When an XMP sidecar provides GPS coordinates, call UpdateLocation()
immediately so the S2 cell is resolved and cached in the local DB.
Without this, subsequent re-indexes always triggered a live geocoding
request (even though the coordinates were already known), producing a
spurious error on every re-index pass.

Downgrade the geocoding failure log in photo_location.go and
places/cell.go from Errorf to Warnf: a transient network failure to
the places service is non-fatal (the photo is indexed successfully,
just without a resolved place name) and must not surface as an
indexing error in the test suite.
This commit is contained in:
Cathie Integra 2026-07-10 10:13:31 +02:00
parent 98aa4d24ea
commit fb6e17ee69
3 changed files with 11 additions and 2 deletions

View file

@ -366,7 +366,7 @@ func (m *Photo) UpdateLocation() (keywords []string, labels classify.Labels) {
// Empty or unknown S2 cell id... should not happen, unless coordinates are invalid.
log.Warnf("photo: unknown cell id for lat %f, lng %f (uid %s)", m.PhotoLat, m.PhotoLng, m.PhotoUID)
} else if err := loc.Find(GeoApi); err != nil {
log.Errorf("photo: %s (find location)", err)
log.Warnf("photo: %s (find location)", err)
} else if loc.Place == nil {
log.Warnf("photo: failed fetching geo data (uid %s, cell %s)", m.PhotoUID, loc.ID)
} else if loc.ID != UnknownLocation.ID {

View file

@ -486,6 +486,15 @@ func (ind *Index) UserMediaFile(m *MediaFile, o IndexOptions, originalName, phot
photo.SetCoordinates(data.Lat, data.Lng, data.Altitude, entity.SrcXmp)
photo.SetCameraSerial(data.CameraSerial)
// Resolve the S2 cell when XMP provides GPS coordinates so subsequent
// re-indexes find the cell in the local DB and do not trigger a live
// geocoding request.
if data.Lat != 0 || data.Lng != 0 {
var locLabels classify.Labels
locKeywords, locLabels = photo.UpdateLocation()
labels = append(labels, locLabels...)
}
// Update metadata details.
details.SetKeywords(data.Keywords.String(), entity.SrcXmp)
details.SetNotes(data.Notes, entity.SrcXmp)

View file

@ -62,7 +62,7 @@ func Cell(id string, locale string) (result Location, err error) {
// Failed?
if err != nil {
log.Errorf("places: location request to %s failed (%s)", serviceHost(reqUrl), safeError(err))
log.Warnf("places: location request to %s failed (%s)", serviceHost(reqUrl), safeError(err))
return result, err
} else if r == nil {
err = fmt.Errorf("location request could not be performed")