Delete temp file if move fails because file already exists
@@ -248,8 +248,11 @@ public class FileReceiver {
log.log(LogLevel.DEBUG, "File moved from " + tempFile.getAbsolutePath()+ " to " + destination.getAbsolutePath());
} 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)
+ // so it might be written already). Delete temp file in that case, to avoid filling the disk.
log.log(LogLevel.DEBUG, "File '" + destination.getAbsolutePath() + "' already exists, continuing: " + e.getMessage());
+ try {
+ Files.delete(tempFile.toPath());
+ } catch (IOException ioe) { /* ignore failure */}
} catch (IOException e) {
String message = "Failed moving file '" + tempFile.getAbsolutePath() + "' to '" + destination.getAbsolutePath() + "'";
log.log(LogLevel.ERROR, message, e);
