You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2019/04/07 23:57:29 UTC
[incubator-iotdb] 01/01: replace renameTo() with
FileUtils.moveFile()
This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch fix_rename_in_version
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit f949dd92658075a5270e02bf96fc790693ba4280
Author: 江天 <jt...@163.com>
AuthorDate: Mon Apr 8 07:56:16 2019 +0800
replace renameTo() with FileUtils.moveFile()
---
.../iotdb/db/engine/version/SimpleFileVersionController.java | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/version/SimpleFileVersionController.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/version/SimpleFileVersionController.java
index c8ba1fb..07d5e7d 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/version/SimpleFileVersionController.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/version/SimpleFileVersionController.java
@@ -24,6 +24,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
+import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -77,11 +78,7 @@ public class SimpleFileVersionController implements VersionController {
private void persist() throws IOException {
File oldFile = new File(directoryPath, FILE_PREFIX + prevVersion);
File newFile = new File(directoryPath, FILE_PREFIX + currVersion);
- if (!oldFile.renameTo(newFile)) {
- throw new IOException(String
- .format("can not rename file %s to file %s", oldFile.getAbsolutePath(),
- newFile.getAbsolutePath()));
- }
+ FileUtils.moveFile(oldFile, newFile);
prevVersion = currVersion;
}