Skip to content

Commit

Permalink
Galleries regenerate on scan
Browse files Browse the repository at this point in the history
  • Loading branch information
exl3m committed Nov 13, 2021
1 parent 0d76fed commit c5d4829
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
2 changes: 2 additions & 0 deletions pkg/image/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ func (scanner *Scanner) ScanExisting(existing file.FileBased, file file.SourceFi
}

scanner.PluginCache.ExecutePostHooks(scanner.Ctx, retImage.ID, plugin.ImageUpdatePost, nil, nil)
} else {
retImage = i
}

return
Expand Down
52 changes: 26 additions & 26 deletions pkg/manager/task_scan_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,33 @@ func (t *ScanTask) scanImage() {
logger.Error(err.Error())
return
}
}

if i != nil {
if t.zipGallery != nil {
// associate with gallery
if err := t.TxnManager.WithTxn(context.TODO(), func(r models.Repository) error {
return gallery.AddImage(r.Gallery(), t.zipGallery.ID, i.ID)
}); err != nil {
logger.Error(err.Error())
return
}
} else if config.GetInstance().GetCreateGalleriesFromFolders() {
// create gallery from folder or associate with existing gallery
logger.Infof("Associating image %s with folder gallery", i.Path)
var galleryID int
var isNewGallery bool
if err := t.TxnManager.WithTxn(context.TODO(), func(r models.Repository) error {
var err error
galleryID, isNewGallery, err = t.associateImageWithFolderGallery(i.ID, r.Gallery())
return err
}); err != nil {
logger.Error(err.Error())
return
}

if i != nil {
if t.zipGallery != nil {
// associate with gallery
if err := t.TxnManager.WithTxn(context.TODO(), func(r models.Repository) error {
return gallery.AddImage(r.Gallery(), t.zipGallery.ID, i.ID)
}); err != nil {
logger.Error(err.Error())
return
}
} else if config.GetInstance().GetCreateGalleriesFromFolders() {
// create gallery from folder or associate with existing gallery
logger.Infof("Associating image %s with folder gallery", i.Path)
var galleryID int
var isNewGallery bool
if err := t.TxnManager.WithTxn(context.TODO(), func(r models.Repository) error {
var err error
galleryID, isNewGallery, err = t.associateImageWithFolderGallery(i.ID, r.Gallery())
return err
}); err != nil {
logger.Error(err.Error())
return
}

if isNewGallery {
GetInstance().PluginCache.ExecutePostHooks(t.ctx, galleryID, plugin.GalleryCreatePost, nil, nil)
}
if isNewGallery {
GetInstance().PluginCache.ExecutePostHooks(t.ctx, galleryID, plugin.GalleryCreatePost, nil, nil)
}
}
}
Expand Down

0 comments on commit c5d4829

Please sign in to comment.