Check if gallery is already associated during scanning (#1154)

This commit is contained in:
bnkai
2021-03-01 07:37:55 +02:00
committed by GitHub
parent 4825de7d35
commit fe990e00c1
2 changed files with 14 additions and 5 deletions

View File

@@ -315,14 +315,22 @@ func (t *ScanTask) associateGallery(wg *sizedwaitgroup.SizedWaitGroup) {
scene, _ := sqb.FindByPath(scenePath) scene, _ := sqb.FindByPath(scenePath)
// found related Scene // found related Scene
if scene != nil { if scene != nil {
logger.Infof("associate: Gallery %s is related to scene: %d", t.FilePath, scene.ID) sceneGalleries, _ := sqb.FindByGalleryID(g.ID) // check if gallery is already associated to the scene
isAssoc := false
if err := sqb.UpdateGalleries(scene.ID, []int{g.ID}); err != nil { for _, sg := range sceneGalleries {
return err if scene.ID == sg.ID {
isAssoc = true
break
}
}
if !isAssoc {
logger.Infof("associate: Gallery %s is related to scene: %d", t.FilePath, scene.ID)
if err := sqb.UpdateGalleries(scene.ID, []int{g.ID}); err != nil {
return err
}
} }
} }
} }
return nil return nil
}); err != nil { }); err != nil {
logger.Error(err.Error()) logger.Error(err.Error())

View File

@@ -8,6 +8,7 @@
* Added Rescan button to scene, image, gallery details overflow button. * Added Rescan button to scene, image, gallery details overflow button.
### 🐛 Bug fixes ### 🐛 Bug fixes
* Fix scan re-associating galleries to the same scene.
* Fix SQL error when filtering galleries excluding performers or tags. * Fix SQL error when filtering galleries excluding performers or tags.
* Fix version checking for armv7 and arm64. * Fix version checking for armv7 and arm64.
* Change "Is NULL" filter to include empty string values. * Change "Is NULL" filter to include empty string values.