diff --git a/internal/entity/photo.go b/internal/entity/photo.go index 27f5e984e..d3c834c4f 100644 --- a/internal/entity/photo.go +++ b/internal/entity/photo.go @@ -52,7 +52,7 @@ type Photo struct { TimeZone string `gorm:"type:varbinary(64);" json:"TimeZone" yaml:"-"` PlaceID string `gorm:"type:varbinary(16);index;" json:"PlaceID" yaml:"-"` LocationID string `gorm:"type:varbinary(16);index;" json:"LocationID" yaml:"-"` - LocSrc string `gorm:"type:varbinary(8);" json:"LocSrc" yaml:"-"` + LocSrc string `gorm:"type:varbinary(8);" json:"LocSrc" yaml:"LocSrc,omitempty"` PhotoLat float32 `gorm:"type:FLOAT;index;" json:"Lat" yaml:"Lat,omitempty"` PhotoLng float32 `gorm:"type:FLOAT;index;" json:"Lng" yaml:"Lng,omitempty"` PhotoAltitude int `json:"Altitude" yaml:"Altitude,omitempty"` @@ -479,7 +479,7 @@ func (m *Photo) LoadPlace() error { // HasLatLng checks if the photo has a latitude and longitude. func (m *Photo) HasLatLng() bool { - return m.PhotoLat != 0 && m.PhotoLng != 0 + return m.PhotoLat != 0.0 || m.PhotoLng != 0.0 } // NoLatLng checks if latitude and longitude are missing. @@ -755,7 +755,7 @@ func (m *Photo) UpdateYearMonth() { // SetCoordinates changes the photo lat, lng and altitude if not empty and from the same source. func (m *Photo) SetCoordinates(lat, lng float32, altitude int, source string) { - if lat == 0 && lng == 0 { + if lat == 0.0 && lng == 0.0 { return } diff --git a/internal/entity/photo_location.go b/internal/entity/photo_location.go index 0b83ab726..0308ca611 100644 --- a/internal/entity/photo_location.go +++ b/internal/entity/photo_location.go @@ -105,6 +105,8 @@ func (m *Photo) UpdateLocation(geoApi string) (keywords []string, labels classif } else if err := m.LoadLocation(); err == nil { m.Place = m.Location.Place m.PlaceID = m.Location.PlaceID + } else { + log.Warn(err) } if m.UnknownPlace() { @@ -112,6 +114,8 @@ func (m *Photo) UpdateLocation(geoApi string) (keywords []string, labels classif m.PlaceID = UnknownPlace.ID } else if err := m.LoadPlace(); err == nil { m.PhotoCountry = m.Place.CountryCode() + } else { + log.Warn(err) } if m.UnknownCountry() { diff --git a/internal/photoprism/index_mediafile.go b/internal/photoprism/index_mediafile.go index 2c8c9cc68..5ac0c7b17 100644 --- a/internal/photoprism/index_mediafile.go +++ b/internal/photoprism/index_mediafile.go @@ -138,6 +138,14 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName string) ( entity.UnscopedDb().Model(&photo).Related(&description) } else { photo.PhotoQuality = -1 + + if yamlName := fs.TypeYaml.FindSub(m.FileName(), fs.HiddenPath, ind.conf.Settings().Index.Group); yamlName != "" { + if err := photo.LoadFromYaml(yamlName); err != nil { + log.Errorf("index: %s (restore from yaml) for %s", err.Error(), quotedName) + } else { + log.Infof("index: restored from %s", txt.Quote(fs.RelativeName(yamlName, ind.originalsPath()))) + } + } } if fileHash == "" { @@ -385,16 +393,6 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName string) ( return result } } else { - if yamlName := fs.TypeYaml.FindSub(m.FileName(), fs.HiddenPath, ind.conf.Settings().Index.Group); yamlName != "" { - if err := photo.LoadFromYaml(yamlName); err != nil { - log.Errorf("index: %s (restore from yaml) for %s", err.Error(), quotedName) - } else { - log.Infof("index: restored from %s", txt.Quote(fs.RelativeName(yamlName, ind.originalsPath()))) - } - } else { - photo.PhotoFavorite = false - } - if err := entity.UnscopedDb().Create(&photo).Error; err != nil { log.Errorf("index: %s", err) result.Status = IndexFailed