Index: Set appearance of video files based on their primary image #3559
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
parent
0e4ce95ff1
commit
c0ee909971
2 changed files with 5 additions and 4 deletions
|
@ -446,7 +446,7 @@ func (m *File) Save() error {
|
||||||
return m.ResolvePrimary()
|
return m.ResolvePrimary()
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateVideoInfos updates missing video metadata from the primary image.
|
// UpdateVideoInfos updated related video files so they are properly grouped with the primary image in search results.
|
||||||
// see https://github.com/photoprism/photoprism/pull/3588#issuecomment-1683429455
|
// see https://github.com/photoprism/photoprism/pull/3588#issuecomment-1683429455
|
||||||
func (m *File) UpdateVideoInfos() error {
|
func (m *File) UpdateVideoInfos() error {
|
||||||
if m.PhotoID <= 0 {
|
if m.PhotoID <= 0 {
|
||||||
|
@ -469,7 +469,7 @@ func (m *File) UpdateVideoInfos() error {
|
||||||
|
|
||||||
if err := deepcopier.Copy(&appearance).From(m); err != nil {
|
if err := deepcopier.Copy(&appearance).From(m); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if err = Db().Model(File{}).Where("photo_id = ? AND file_video = 1 AND file_diff <= 0", m.PhotoID).Updates(appearance).Error; err != nil {
|
} else if err = Db().Model(File{}).Where("photo_id = ? AND file_video = 1", m.PhotoID).Updates(appearance).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -906,9 +906,10 @@ func (ind *Index) UserMediaFile(m *MediaFile, o IndexOptions, originalName, phot
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update related video files so they are properly grouped with the primary image in search results.
|
||||||
if (photo.PhotoType == entity.MediaVideo || photo.PhotoType == entity.MediaLive) && file.FilePrimary {
|
if (photo.PhotoType == entity.MediaVideo || photo.PhotoType == entity.MediaLive) && file.FilePrimary {
|
||||||
if err := file.UpdateVideoInfos(); err != nil {
|
if updateErr := file.UpdateVideoInfos(); updateErr != nil {
|
||||||
log.Errorf("index: %s in %s (update video infos)", err, logName)
|
log.Errorf("index: %s in %s (update video infos)", updateErr, logName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue