Close even more resources
This commit is contained in:
@@ -100,8 +100,10 @@ public class UploadService {
|
|||||||
uploadedFile.downloadUrl = "/api/public/upload/" + user + "/" + uploadedFile.iv;
|
uploadedFile.downloadUrl = "/api/public/upload/" + user + "/" + uploadedFile.iv;
|
||||||
Optional<Path> filePathOptional;
|
Optional<Path> filePathOptional;
|
||||||
try {
|
try {
|
||||||
filePathOptional = Files.list(p)
|
Stream<Path> stream2 = Files.list(p)
|
||||||
.filter(p2 -> !p2.getFileName().toString().equals(".key")).findFirst();
|
.filter(p2 -> !p2.getFileName().toString().equals(".key"));
|
||||||
|
filePathOptional = stream.findFirst();
|
||||||
|
stream2.close();
|
||||||
if (filePathOptional.isPresent()) {
|
if (filePathOptional.isPresent()) {
|
||||||
uploadedFile.name = filePathOptional.get().getFileName().toString();
|
uploadedFile.name = filePathOptional.get().getFileName().toString();
|
||||||
uploadedFiles.add(uploadedFile);
|
uploadedFiles.add(uploadedFile);
|
||||||
@@ -136,8 +138,10 @@ public class UploadService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Optional<Path> filePathOptional = Files.list(folderPath)
|
Stream<Path> stream = Files.list(folderPath)
|
||||||
.filter(p -> !p.getFileName().toString().equals(".key")).findFirst();
|
.filter(p -> !p.getFileName().toString().equals(".key"));
|
||||||
|
Optional<Path> filePathOptional = stream.findFirst();
|
||||||
|
stream.close();
|
||||||
if (!filePathOptional.isPresent()) {
|
if (!filePathOptional.isPresent()) {
|
||||||
return Response.status(Response.Status.NOT_FOUND).build();
|
return Response.status(Response.Status.NOT_FOUND).build();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user