Commit d8ec8803 authored by Enriko Käsper's avatar Enriko Käsper
Browse files

Merge branch 'hotfix/TEIS-2874' into develop

parents edf57b44 130d1375
# Changelog
## [1.23.2] - 2022-02-18
* TEIS-2874: make file hard delete method idempotent
## [1.23.0] - 2022-01-12
* TEIS-2787: updated virus-scan timeout; updated PollVirusScanResultTask and UploadFileVirusScanTask error handling
......
......@@ -150,4 +150,16 @@ class FileMsListenerTest extends FilesServiceAppTestBase {
List<FilePointerEntity> filePointers = filePointerRepository.findByFileId(file.getFileId());
assertThat(filePointers).isEmpty();
}
@Test
void delete_alreadyDeletedFileWithoutPointer_success() {
DeleteFile file = new DeleteFile();
file.setFileId(UUID.randomUUID());
file.setHardDelete(true);
deleteFileRequest.setPayload(file, requestMetaDTO);
DeleteFileResponse response = listener.delete(deleteFileRequest);
assertThat(response.getError()).isNull();
}
}
......@@ -56,6 +56,10 @@ public class DeleteFileTask implements JavaDelegate {
}
private void hardDeleteFile(UUID fileId, FileEntity file) {
if (file == null) {
log.info("File with id [{}] is already deleted", fileId);
return;
}
if (file.getFileStatus().equals(FAILED)) {
log.info("File with id [{}] will not be deleted because file status is FAILED", fileId);
return;
......
......@@ -87,6 +87,10 @@ public class FileBusinessMsService {
List<FilePointerEntity> filePointers = filePointerDataService.getByFileId(domain.getFileId());
if (domain.isHardDelete() && filePointers.isEmpty()) {
FileEntity file = dataService.getById(domain.getFileId());
if (file == null) {
log.info("File with id [{}] already deleted", domain.getFileId());
return;
}
try {
fileStorageServiceClient.deleteFile(file.getBucket(), domain.getFileId());
} catch (Exception e) {
......
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