Skip to content

Commit fb6e17e

Browse files
committed
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.
1 parent 98aa4d2 commit fb6e17e

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

internal/entity/photo_location.go

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

internal/photoprism/index_mediafile.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,15 @@ func (ind *Index) UserMediaFile(m *MediaFile, o IndexOptions, originalName, phot
486486
photo.SetCoordinates(data.Lat, data.Lng, data.Altitude, entity.SrcXmp)
487487
photo.SetCameraSerial(data.CameraSerial)
488488

489+
// Resolve the S2 cell when XMP provides GPS coordinates so subsequent
490+
// re-indexes find the cell in the local DB and do not trigger a live
491+
// geocoding request.
492+
if data.Lat != 0 || data.Lng != 0 {
493+
var locLabels classify.Labels
494+
locKeywords, locLabels = photo.UpdateLocation()
495+
labels = append(labels, locLabels...)
496+
}
497+
489498
// Update metadata details.
490499
details.SetKeywords(data.Keywords.String(), entity.SrcXmp)
491500
details.SetNotes(data.Notes, entity.SrcXmp)

internal/service/hub/places/cell.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func Cell(id string, locale string) (result Location, err error) {
6262

6363
// Failed?
6464
if err != nil {
65-
log.Errorf("places: location request to %s failed (%s)", serviceHost(reqUrl), safeError(err))
65+
log.Warnf("places: location request to %s failed (%s)", serviceHost(reqUrl), safeError(err))
6666
return result, err
6767
} else if r == nil {
6868
err = fmt.Errorf("location request could not be performed")

0 commit comments

Comments
 (0)