mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Don't add duplicate scenes,galleries to the DB
This commit is contained in:
@@ -46,9 +46,15 @@ func (t *ScanTask) scanGallery() {
|
|||||||
tx := database.DB.MustBeginTx(ctx, nil)
|
tx := database.DB.MustBeginTx(ctx, nil)
|
||||||
gallery, _ = qb.FindByChecksum(checksum, tx)
|
gallery, _ = qb.FindByChecksum(checksum, tx)
|
||||||
if gallery != nil {
|
if gallery != nil {
|
||||||
|
exists, _ := utils.FileExists(t.FilePath)
|
||||||
|
if exists {
|
||||||
|
logger.Infof("%s already exists. Duplicate of %s ", t.FilePath, gallery.Path)
|
||||||
|
} else {
|
||||||
|
|
||||||
logger.Infof("%s already exists. Updating path...", t.FilePath)
|
logger.Infof("%s already exists. Updating path...", t.FilePath)
|
||||||
gallery.Path = t.FilePath
|
gallery.Path = t.FilePath
|
||||||
_, err = qb.Update(*gallery, tx)
|
_, err = qb.Update(*gallery, tx)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.Infof("%s doesn't exist. Creating new item...", t.FilePath)
|
logger.Infof("%s doesn't exist. Creating new item...", t.FilePath)
|
||||||
currentTime := time.Now()
|
currentTime := time.Now()
|
||||||
@@ -95,9 +101,14 @@ func (t *ScanTask) scanScene() {
|
|||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
tx := database.DB.MustBeginTx(ctx, nil)
|
tx := database.DB.MustBeginTx(ctx, nil)
|
||||||
if scene != nil {
|
if scene != nil {
|
||||||
|
exists, _ := utils.FileExists(t.FilePath)
|
||||||
|
if exists {
|
||||||
|
logger.Infof("%s already exists. Duplicate of %s ", t.FilePath, scene.Path)
|
||||||
|
} else {
|
||||||
logger.Infof("%s already exists. Updating path...", t.FilePath)
|
logger.Infof("%s already exists. Updating path...", t.FilePath)
|
||||||
scene.Path = t.FilePath
|
scene.Path = t.FilePath
|
||||||
_, err = qb.Update(*scene, tx)
|
_, err = qb.Update(*scene, tx)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.Infof("%s doesn't exist. Creating new item...", t.FilePath)
|
logger.Infof("%s doesn't exist. Creating new item...", t.FilePath)
|
||||||
currentTime := time.Now()
|
currentTime := time.Now()
|
||||||
|
|||||||
Reference in New Issue
Block a user