diff options
author | Harald Musum <musum@verizonmedia.com> | 2019-07-17 13:14:09 +0200 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2019-07-17 13:14:09 +0200 |
commit | b843c745dcb297e718ddbbff6e1d531d3e193361 (patch) | |
tree | b95017bbc38192aa0ab75b5b8db96d114a845626 /filedistribution | |
parent | c4dfcdbff503e42684251c8d230da093ba836148 (diff) |
Log at level INFO when file already exists
Diffstat (limited to 'filedistribution')
-rw-r--r-- | filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReceiver.java | 24 |
1 files changed, 15 insertions, 9 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 60a5e25b3e0..c4487252e27 100644 --- a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReceiver.java +++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReceiver.java @@ -193,15 +193,9 @@ 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(LogLevel.DEBUG, () -> "File '" + destination.getAbsolutePath() + "' already exists, continuing: " + e.getMessage()); - try { - if (tempFile.isDirectory()) - IOUtils.recursiveDeleteDir(tempFile); - else - Files.delete(tempFile.toPath()); - } catch (IOException ioe) { - log.log(LogLevel.WARNING, "Failed deleting file/dir " + tempFile); - } + log.log(LogLevel.INFO, "Failed moving file '" + tempFile.getAbsolutePath() + "' to '" + destination.getAbsolutePath() + + "', '" + destination.getAbsolutePath() + "' already exists"); + deleteFileOrDirectory(tempFile); } catch (IOException e) { String message = "Failed moving file '" + tempFile.getAbsolutePath() + "' to '" + destination.getAbsolutePath() + "'"; log.log(LogLevel.ERROR, message, e); @@ -209,6 +203,18 @@ public class FileReceiver { } } + private static void deleteFileOrDirectory(File path) { + if ( ! path.exists()) return; + try { + if (path.isDirectory()) + IOUtils.recursiveDeleteDir(path); + else + Files.delete(path.toPath()); + } catch (IOException ioe) { + log.log(LogLevel.WARNING, "Failed deleting file/dir " + path); + } + } + private void receiveFileMeta(Request req) { log.log(LogLevel.DEBUG, () -> "Received method call '" + req.methodName() + "' with parameters : " + req.parameters()); FileReference reference = new FileReference(req.parameters().get(0).asString()); |