fix(list): when list background is removed, delete file from file system and DB (#1372)
Co-authored-by: testinho.testador <testinho.testador@noreply.kolaente.de> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/1372 Reviewed-by: konrad <k@knt.li> Co-authored-by: clos <clos@noreply.kolaente.de> Co-committed-by: clos <clos@noreply.kolaente.de>
This commit is contained in:
@ -341,6 +341,11 @@ func RemoveListBackground(c echo.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = list.DeleteBackgroundFileIfExists()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
list.BackgroundFileID = 0
|
||||
list.BackgroundInformation = nil
|
||||
list.BackgroundBlurHash = ""
|
||||
|
@ -54,11 +54,9 @@ func (p *Provider) Search(s *xorm.Session, search string, page int64) (result []
|
||||
// @Router /lists/{id}/backgrounds/upload [put]
|
||||
func (p *Provider) Set(s *xorm.Session, img *background.Image, list *models.List, auth web.Auth) (err error) {
|
||||
// Remove the old background if one exists
|
||||
if list.BackgroundFileID != 0 {
|
||||
file := files.File{ID: list.BackgroundFileID}
|
||||
if err := file.Delete(); err != nil {
|
||||
return err
|
||||
}
|
||||
err = list.DeleteBackgroundFileIfExists()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
file := &files.File{}
|
||||
|
Reference in New Issue
Block a user