From a0891f744a6f1b3e3d24d0bb88dae978082507f3 Mon Sep 17 00:00:00 2001 From: kaloyane <kaloyane> Date: Tue, 25 Oct 2011 07:32:13 +0000 Subject: [PATCH] revert 23445: Jython move command should move files to their destination even when the "dest" directory exists. SVN: 23404 --- .../api/v1/impl/MoveFileCommand.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/MoveFileCommand.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/MoveFileCommand.java index 35bcdd38ef2..0e4e5477341 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/MoveFileCommand.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/MoveFileCommand.java @@ -20,7 +20,8 @@ import java.io.File; import java.io.IOException; import ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked; -import ch.systemsx.cisd.etlserver.FileRenamer; +import ch.systemsx.cisd.common.filesystem.FileOperations; +import ch.systemsx.cisd.common.filesystem.IFileOperations; /** * Does a move if the destination is an existing directory, a rename otherwise. @@ -59,7 +60,7 @@ public class MoveFileCommand extends AbstractTransactionalCommand throw new IOExceptionUnchecked(checkedException); } - FileRenamer.renameAndLog(src, dst); + moveFile(src, dst); } public void rollback() @@ -81,7 +82,17 @@ public class MoveFileCommand extends AbstractTransactionalCommand return; } - FileRenamer.renameAndLog(dst, src); + moveFile(dst, src); + } + + private void moveFile(File from, File to) + { + String entity = from.isFile() ? "file" : "direcrtory"; + getOperationLog().info( + String.format("Moving %s '%s' to '%s'", entity, from.getAbsolutePath(), + to.getAbsolutePath())); + IFileOperations fileOperations = FileOperations.getMonitoredInstanceForCurrentThread(); + fileOperations.move(from, to); } @Override -- GitLab