[Files Refactor] Bug fixes (#2868)

* Return error if multiple rows returned for id
* Add missing LoadFiles calls
* Show id if path is empty
This commit is contained in:
WithoutPants
2022-09-02 11:18:37 +10:00
parent 273cf0383d
commit 94d39da706
23 changed files with 93 additions and 26 deletions

View File

@@ -81,6 +81,10 @@ func (s *Service) destroyImage(ctx context.Context, i *models.Image, fileDeleter
// deleteFiles deletes files for the image from the database and file system, if they are not in use by other images
func (s *Service) deleteFiles(ctx context.Context, i *models.Image, fileDeleter *FileDeleter) error {
if err := i.LoadFiles(ctx, s.Repository); err != nil {
return err
}
for _, f := range i.Files.List() {
// only delete files where there is no other associated image
otherImages, err := s.Repository.FindByFileID(ctx, f.ID)