Moments: Update folder search filter when path changes
This commit is contained in:
parent
35659f25cf
commit
5383553cd1
2 changed files with 7 additions and 6 deletions
|
@ -315,15 +315,16 @@ func (m *Album) SaveForm(f form.Album) error {
|
|||
return Db().Save(m).Error
|
||||
}
|
||||
|
||||
// Updates a column in the database.
|
||||
// Update sets a new value for a database column.
|
||||
func (m *Album) Update(attr string, value interface{}) error {
|
||||
return UnscopedDb().Model(m).UpdateColumn(attr, value).Error
|
||||
}
|
||||
|
||||
// UpdatePath sets a unique path for an albums.
|
||||
func (m *Album) UpdatePath(albumPath string) error {
|
||||
// UpdateFolder updates the path, filter and slug for a folder album.
|
||||
func (m *Album) UpdateFolder(albumPath, albumFilter string) error {
|
||||
if err := UnscopedDb().Model(m).UpdateColumns(map[string]interface{}{
|
||||
"AlbumPath": albumPath,
|
||||
"AlbumFilter": albumFilter,
|
||||
"AlbumSlug": slug.Make(albumPath),
|
||||
}).Error; err != nil {
|
||||
return err
|
||||
|
|
|
@ -76,8 +76,8 @@ func (m *Moments) Start() (err error) {
|
|||
if a.DeletedAt != nil {
|
||||
// Nothing to do.
|
||||
log.Tracef("moments: %s was deleted (%s)", txt.Quote(a.AlbumTitle), a.AlbumFilter)
|
||||
} else if err := a.UpdatePath(mom.Path); err != nil {
|
||||
log.Errorf("moments: %s (update folder album)", err.Error())
|
||||
} else if err := a.UpdateFolder(mom.Path, f.Serialize()); err != nil {
|
||||
log.Errorf("moments: %s (update folder)", err.Error())
|
||||
} else {
|
||||
log.Tracef("moments: %s already exists (%s)", txt.Quote(a.AlbumTitle), a.AlbumFilter)
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ func (m *Moments) Start() (err error) {
|
|||
a.AlbumCountry = mom.FolderCountry
|
||||
|
||||
if err := a.Create(); err != nil {
|
||||
log.Errorf("moments: %s (create folder album)", err)
|
||||
log.Errorf("moments: %s (create folder)", err)
|
||||
} else {
|
||||
log.Infof("moments: added %s (%s)", txt.Quote(a.AlbumTitle), a.AlbumFilter)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue