Skip to content
Snippets Groups Projects
Commit bad46063 authored by Grégory Mantelet's avatar Grégory Mantelet
Browse files

[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.
parent 7bd91a1c
No related branches found
No related tags found
No related merge requests found
...@@ -22,13 +22,14 @@ package uws.service.file.io; ...@@ -22,13 +22,14 @@ package uws.service.file.io;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
/** /**
* This close action rename a given file into another one. The target file is * This close action rename a given file into another one. The target file is
* deleted if it already exists. * deleted if it already exists.
* *
* @author Grégory Mantelet (CDS) * @author Grégory Mantelet (CDS)
* @version 4.4 (07/2018) * @version 4.4 (10/2018)
* @since 4.4 * @since 4.4
*/ */
public class RotateFileAction implements CloseAction { public class RotateFileAction implements CloseAction {
...@@ -81,7 +82,7 @@ public class RotateFileAction implements CloseAction { ...@@ -81,7 +82,7 @@ public class RotateFileAction implements CloseAction {
// Finally rename the source file into the given target file: // Finally rename the source file into the given target file:
try{ try{
Files.move(sourceFile.toPath(), targetFile.toPath()); Files.move(sourceFile.toPath(), targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
}catch(IOException ioe){ }catch(IOException ioe){
throw new IOException("Impossible to perform the file rotation! Cause: [" + ioe.getClass() + "] " + ioe.getMessage(), ioe); throw new IOException("Impossible to perform the file rotation! Cause: [" + ioe.getClass() + "] " + ioe.getMessage(), ioe);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment