summaryrefslogtreecommitdiffstats
path: root/filedistribution
diff options
context:
space:
mode:
Diffstat (limited to 'filedistribution')
-rw-r--r--filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReceiver.java11
1 files changed, 5 insertions, 6 deletions
diff --git a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReceiver.java b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReceiver.java
index 89a77599909..a2c5fee1e51 100644
--- a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReceiver.java
+++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReceiver.java
@@ -131,9 +131,7 @@ public class FileReceiver {
throw new RuntimeException("Failed writing file: ", e);
} finally {
try {
- if (inprogressFile.exists()) {
- Files.delete(inprogressFile.toPath());
- }
+ Files.deleteIfExists(inprogressFile.toPath());
} catch (IOException e) {
log.log(Level.SEVERE, "Failed deleting " + inprogressFile.getAbsolutePath() + ": " + e.getMessage(), e);
}
@@ -191,13 +189,14 @@ public class FileReceiver {
} catch (FileAlreadyExistsException e) {
// Don't fail if it already exists (we might get the file from several config servers when retrying, servers are down etc.
// so it might be written already). Delete temp file/dir in that case, to avoid filling the disk.
- log.log(Level.FINE, () -> "Failed moving file '" + tempFile.getAbsolutePath() + "' to '" + destination.getAbsolutePath() +
- "', '" + destination.getAbsolutePath() + "' already exists");
- deleteFileOrDirectory(tempFile);
+ log.log(Level.FINE, () -> "Failed moving file '" + tempFile.getAbsolutePath() + "' to '" +
+ destination.getAbsolutePath() + "', it already exists");
} catch (IOException e) {
String message = "Failed moving file '" + tempFile.getAbsolutePath() + "' to '" + destination.getAbsolutePath() + "'";
log.log(Level.SEVERE, message, e);
throw new RuntimeException(message, e);
+ } finally {
+ deleteFileOrDirectory(tempFile);
}
}