Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
fix: Delete project image only if present
Browse files Browse the repository at this point in the history
  • Loading branch information
devkcud committed Oct 27, 2024
1 parent 0b53830 commit 9fab597
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions internal/service/repository/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -801,9 +801,11 @@ func (pr *projectRepository) UnsafeDelete(id uint) error {
return err
}

if err := aws.DeleteProjectImage(project.BannerURL); err != nil {
tx.Rollback()
return err
if project.BannerURL != "" {
if err := aws.DeleteProjectImage(project.BannerURL); err != nil {
tx.Rollback()
return err
}
}

if err := tx.Unscoped().Delete(&project).Error; err != nil {
Expand Down Expand Up @@ -899,9 +901,11 @@ func (pr *projectRepository) ClearTrash(userID uint) error {
}

for _, project := range projects {
if err := aws.DeleteProjectImage(project.BannerURL); err != nil {
tx.Rollback()
return err
if project.BannerURL != "" {
if err := aws.DeleteProjectImage(project.BannerURL); err != nil {
tx.Rollback()
return err
}
}
}

Expand Down

0 comments on commit 9fab597

Please sign in to comment.