From bad46063cb2c25397c80ac533cba1f5c7190bdfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Mantelet?= <gregory.mantelet@astro.unistra.fr> Date: Mon, 22 Oct 2018 14:13:32 +0200 Subject: [PATCH] [UWS, TAP] Ensure the backup file rotation always deletes the temporary backup file (actually, replaces the real backup file by the temporary one). Sometimes a temporary backup file (i.e. a file named like `*.backup.temp-*`) is not deleted. This means that the log rotation fails and that, potentially, some jobs have not been updated/deleted. This commit is there is re-enforce the replacement operation. --- src/uws/service/file/io/RotateFileAction.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/uws/service/file/io/RotateFileAction.java b/src/uws/service/file/io/RotateFileAction.java index 1283037..88929db 100644 --- a/src/uws/service/file/io/RotateFileAction.java +++ b/src/uws/service/file/io/RotateFileAction.java @@ -22,13 +22,14 @@ package uws.service.file.io; import java.io.File; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.StandardCopyOption; /** * This close action rename a given file into another one. The target file is * deleted if it already exists. * * @author Grégory Mantelet (CDS) - * @version 4.4 (07/2018) + * @version 4.4 (10/2018) * @since 4.4 */ public class RotateFileAction implements CloseAction { @@ -81,7 +82,7 @@ public class RotateFileAction implements CloseAction { // Finally rename the source file into the given target file: try{ - Files.move(sourceFile.toPath(), targetFile.toPath()); + Files.move(sourceFile.toPath(), targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING); }catch(IOException ioe){ throw new IOException("Impossible to perform the file rotation! Cause: [" + ioe.getClass() + "] " + ioe.getMessage(), ioe); } -- GitLab