提交 1d417475 authored 作者: Thomas Mueller's avatar Thomas Mueller

MVTableEngine: support online backup on Windows

上级 c3932e12
......@@ -82,7 +82,8 @@ public class BackupCommand extends Prepared {
backupFile(out, base, n);
}
if (n.endsWith(Constants.SUFFIX_MV_FILE)) {
backupFile(out, base, n);
InputStream in = db.getMvStore().getInputStream();
backupFile(out, base, n, in);
}
}
}
......@@ -115,6 +116,11 @@ public class BackupCommand extends Prepared {
}
private static void backupFile(ZipOutputStream out, String base, String fn) throws IOException {
InputStream in = FileUtils.newInputStream(fn);
backupFile(out, base, fn, in);
}
private static void backupFile(ZipOutputStream out, String base, String fn, InputStream in) throws IOException {
String f = FileUtils.toRealPath(fn);
base = FileUtils.toRealPath(base);
if (!f.startsWith(base)) {
......@@ -123,7 +129,6 @@ public class BackupCommand extends Prepared {
f = f.substring(base.length());
f = correctFileName(f);
out.putNextEntry(new ZipEntry(f));
InputStream in = FileUtils.newInputStream(fn);
IOUtils.copyAndCloseInput(in, out);
out.closeEntry();
}
......
......@@ -6,6 +6,7 @@
*/
package org.h2.mvstore.db;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
......@@ -20,6 +21,7 @@ import org.h2.mvstore.DataUtils;
import org.h2.mvstore.MVStore;
import org.h2.mvstore.db.TransactionStore.Transaction;
import org.h2.store.InDoubtTransaction;
import org.h2.store.fs.FileChannelInputStream;
import org.h2.store.fs.FileUtils;
import org.h2.table.RegularTable;
import org.h2.table.TableBase;
......@@ -228,6 +230,10 @@ public class MVTableEngine implements TableEngine {
store.setCacheSize(kb * 1024);
}
public InputStream getInputStream() {
return new FileChannelInputStream(store.getFile());
}
}
/**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论