Commit 89fc0f56 authored by Matija Obreza's avatar Matija Obreza
Browse files

Handle image/file removal better

parent 29fb29f3
......@@ -364,21 +364,24 @@ public class RepositoryServiceImpl implements RepositoryService, InitializingBea
throw new NoSuchRepositoryFileException();
}
bytesStorageService.remove(repositoryFile.getPath(), repositoryFile.getFilename());
if (repositoryFile.getContentType().startsWith("image")) {
repositoryImagePersistence.delete((RepositoryImage) repositoryFile);
} else {
repositoryFilePersistence.delete(repositoryFile);
if (repositoryFile instanceof RepositoryImage) {
return removeImage((RepositoryImage) repositoryFile);
}
bytesStorageService.remove(repositoryFile.getPath(), repositoryFile.getFilename());
repositoryFilePersistence.delete(repositoryFile);
return repositoryFile;
}
@Override
@Transactional
public RepositoryImage removeImage(final RepositoryImage repositoryImage) throws NoSuchRepositoryFileException, IOException {
removeFile(repositoryImage);
if (repositoryImage == null) {
throw new NoSuchRepositoryFileException();
}
bytesStorageService.remove(repositoryImage.getPath(), repositoryImage.getFilename());
repositoryImagePersistence.delete(repositoryImage);
return repositoryImage;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment