diff --git a/pkg/models/unsplash.go b/pkg/models/unsplash.go index 6c9e85296..1820dccf7 100644 --- a/pkg/models/unsplash.go +++ b/pkg/models/unsplash.go @@ -39,8 +39,8 @@ func (u *UnsplashPhoto) TableName() string { } // Save persists an unsplash photo to the db -func (u *UnsplashPhoto) Save() error { - _, err := x.Insert(u) +func (u *UnsplashPhoto) Save(s *xorm.Session) error { + _, err := s.Insert(u) return err } @@ -58,10 +58,10 @@ func GetUnsplashPhotoByFileID(s *xorm.Session, fileID int64) (u *UnsplashPhoto, } // RemoveUnsplashPhoto removes an unsplash photo from the db -func RemoveUnsplashPhoto(fileID int64) (err error) { +func RemoveUnsplashPhoto(s *xorm.Session, fileID int64) (err error) { // This is intentionally "fire and forget" which is why we don't check if we have an // unsplash entry for that file at all. If there is one, it will be deleted. // We do this to keep the function simple. - _, err = x.Where("file_id = ?", fileID).Delete(&UnsplashPhoto{}) + _, err = s.Where("file_id = ?", fileID).Delete(&UnsplashPhoto{}) return } diff --git a/pkg/modules/background/unsplash/unsplash.go b/pkg/modules/background/unsplash/unsplash.go index d7952e1bd..23ff2b3f0 100644 --- a/pkg/modules/background/unsplash/unsplash.go +++ b/pkg/modules/background/unsplash/unsplash.go @@ -292,7 +292,7 @@ func (p *Provider) Set(image *background.Image, list *models.List, auth web.Auth return err } - if err := models.RemoveUnsplashPhoto(list.BackgroundFileID); err != nil { + if err := models.RemoveUnsplashPhoto(s, list.BackgroundFileID); err != nil { return err } } @@ -304,7 +304,7 @@ func (p *Provider) Set(image *background.Image, list *models.List, auth web.Auth Author: photo.User.Username, AuthorName: photo.User.Name, } - err = unsplashPhoto.Save() + err = unsplashPhoto.Save(s) if err != nil { return }