SUPPORT-8836:fixes
This commit is contained in:
parent
384a97d629
commit
1a771c33f9
1 changed files with 9 additions and 12 deletions
|
|
@ -28,9 +28,9 @@ public class FileScanService {
|
|||
File tempFile = null;
|
||||
try {
|
||||
tempFile = saveFile(file);
|
||||
return runKeslScan(tempFile);
|
||||
return runKeslScan(tempFile, file.getOriginalFilename());
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (IOException | InterruptedException e) {
|
||||
throw new AvException("Error scanning file: " + file.getOriginalFilename(), e);
|
||||
}
|
||||
finally {
|
||||
|
|
@ -47,15 +47,14 @@ public class FileScanService {
|
|||
|
||||
private File saveFile(MultipartFile file) throws IOException {
|
||||
Path uploadPath = Paths.get(uploadDirectory);
|
||||
if (!Files.exists(uploadPath)) {
|
||||
Files.createDirectories(uploadPath);
|
||||
}
|
||||
Path tempFile = Files.createTempFile(uploadPath, "kesl-upload-", ".tmp");
|
||||
file.transferTo(tempFile.toFile());
|
||||
return tempFile.toFile();
|
||||
Path tempFilePath = Files.createTempFile(uploadPath, "kesl-upload-", ".tmp");
|
||||
File tempFile = tempFilePath.toFile();
|
||||
file.transferTo(tempFile);
|
||||
return tempFile;
|
||||
}
|
||||
|
||||
private int runKeslScan(File file) throws IOException, InterruptedException {
|
||||
private int runKeslScan(File file, String originalFileName) throws IOException, InterruptedException {
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(KESL_CONTROL, KESL_SCAN,
|
||||
file.getAbsolutePath()
|
||||
);
|
||||
|
|
@ -65,8 +64,6 @@ public class FileScanService {
|
|||
if (exitCode == 0 || exitCode == 72) {
|
||||
return exitCode;
|
||||
}
|
||||
else {
|
||||
throw new AvException("KESL error, exit code: " + exitCode);
|
||||
}
|
||||
throw new AvException("KESL error scanning file: " + originalFileName + ", exit code: " + exitCode);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue