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