Index: Also compare camera serial before stacking a file

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-07-20 12:32:50 +02:00
parent b14bddca9d
commit 54c8a25ff8

View file

@ -102,7 +102,7 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName string) (
fileHash := ""
fileChanged := true
fileExists := false
fileGrouped := false
fileStacked := false
photoExists := false
@ -140,10 +140,10 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName string) (
if photoQuery.Error != nil && m.MetaData().HasTimeAndPlace() {
metaData = m.MetaData()
photoQuery = entity.UnscopedDb().First(&photo, "photo_lat = ? AND photo_lng = ? AND taken_at = ?", metaData.Lat, metaData.Lng, metaData.TakenAt)
photoQuery = entity.UnscopedDb().First(&photo, "photo_lat = ? AND photo_lng = ? AND taken_at = ? AND camera_serial = ?", metaData.Lat, metaData.Lng, metaData.TakenAt, metaData.CameraSerial)
if photoQuery.Error == nil {
fileGrouped = true
fileStacked = true
}
}
@ -151,7 +151,7 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName string) (
photoQuery = entity.UnscopedDb().First(&photo, "uuid = ?", m.MetaData().DocumentID)
if photoQuery.Error == nil {
fileGrouped = true
fileStacked = true
}
}
} else {
@ -662,7 +662,7 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName string) (
"count": 1,
})
if fileGrouped {
if fileStacked {
result.Status = IndexStacked
} else {
result.Status = IndexAdded