Skip to content

The Unified and Autonomous Development Platform

Avoid file already exists error when upgrade

Robin Shenb82cba7773fa
diff --git a/core/src/main/java/io/onedev/server/command/UpgradeCommand.java b/core/src/main/java/io/onedev/server/command/UpgradeCommand.java
index 5a31286ae2..b795c70939 100644
--- a/core/src/main/java/io/onedev/server/command/UpgradeCommand.java
+++ b/core/src/main/java/io/onedev/server/command/UpgradeCommand.java
@@ -132,7 +132,10 @@ public class UpgradeCommand extends DefaultPersistManager {
|| file.getName().contains("ojdbc") || file.getName().contains("postgresql")
|| file.getName().contains("sqljdbc")) {
try {
- FileUtils.moveFileToDirectory(file, new File(upgradeDir, "site/lib"), true);
+ File destDir = new File(upgradeDir, "site/lib");
+ FileUtils.createDir(destDir);
+ FileUtils.copyFileToDirectory(file, destDir);
+ FileUtils.deleteFile(file);
} catch (IOException e) {
throw new RuntimeException(e);
}