提交 f116187d authored 作者: Thomas Mueller's avatar Thomas Mueller

File system abstraction: support replacing existing files using move (currently not for Windows).

上级 25d907e3
......@@ -177,8 +177,8 @@ public class ChangeFileEncryption extends Tool {
for (String fileName : files) {
String temp = dir + "/temp.db";
FileUtils.delete(temp);
FileUtils.moveTo(fileName, temp);
FileUtils.moveTo(temp, fileName);
FileUtils.move(fileName, temp);
FileUtils.move(temp, fileName);
}
// if this worked, the operation will (hopefully) be successful
// TODO changeFileEncryption: this is a workaround!
......@@ -256,7 +256,7 @@ public class ChangeFileEncryption extends Tool {
}
}
FileUtils.delete(fileName);
FileUtils.moveTo(temp, fileName);
FileUtils.move(temp, fileName);
}
private void copy(String fileName, FileStore in, byte[] key) {
......@@ -291,7 +291,7 @@ public class ChangeFileEncryption extends Tool {
in.close();
fileOut.close();
FileUtils.delete(fileName);
FileUtils.moveTo(temp, fileName);
FileUtils.move(temp, fileName);
}
}
......@@ -141,10 +141,10 @@ public class DbUpgrade {
stat.execute("script to '" + script + "'");
}
conn.close();
FileUtils.moveTo(data, backupData);
FileUtils.moveTo(index, backupIndex);
FileUtils.move(data, backupData);
FileUtils.move(index, backupIndex);
if (FileUtils.exists(lobs)) {
FileUtils.moveTo(lobs, backupLobs);
FileUtils.move(lobs, backupLobs);
}
ci.removeProperty("IFEXISTS", false);
conn = new JdbcConnection(ci, true);
......@@ -166,13 +166,13 @@ public class DbUpgrade {
}
} catch (Exception e) {
if (FileUtils.exists(backupData)) {
FileUtils.moveTo(backupData, data);
FileUtils.move(backupData, data);
}
if (FileUtils.exists(backupIndex)) {
FileUtils.moveTo(backupIndex, index);
FileUtils.move(backupIndex, index);
}
if (FileUtils.exists(backupLobs)) {
FileUtils.moveTo(backupLobs, lobs);
FileUtils.move(backupLobs, lobs);
}
FileUtils.delete(name + ".h2.db");
throw DbException.toSQLException(e);
......
......@@ -778,7 +778,7 @@ public class ValueLob extends Value {
private static synchronized void renameFile(DataHandler handler,
String oldName, String newName) {
synchronized (handler.getLobSyncObject()) {
FileUtils.moveTo(oldName, newName);
FileUtils.move(oldName, newName);
}
}
......
......@@ -115,7 +115,7 @@ public class TestKillRestartMulti extends TestBase {
conn.close();
FileUtils.delete(backup);
} catch (SQLException e) {
FileUtils.moveTo(backup, backup + ".error");
FileUtils.move(backup, backup + ".error");
throw e;
}
}
......
......@@ -627,7 +627,7 @@ public class TestTools extends TestBase {
String newTrace = getBaseDir() + "/test.trace.db";
FileUtils.delete(newTrace);
assertFalse(FileUtils.exists(newTrace));
FileUtils.moveTo(trace, newTrace);
FileUtils.move(trace, newTrace);
deleteDb("toolsConvertTraceFile");
Player.main(getBaseDir() + "/test.trace.db");
testTraceFile(url);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论