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

MVTableEngine: support online backup on Windows

上级 35cbaa1f
......@@ -231,7 +231,7 @@ public class MVTableEngine implements TableEngine {
}
public InputStream getInputStream() {
return new FileChannelInputStream(store.getFile());
return new FileChannelInputStream(store.getFile(), false);
}
}
......
......@@ -17,15 +17,18 @@ import java.nio.channels.FileChannel;
public class FileChannelInputStream extends InputStream {
private final FileChannel channel;
private final boolean closeChannel;
private final byte[] buffer = { 0 };
/**
* Create a new file object input stream from the file channel.
*
* @param channel the file channel
* @param closeChannel whether closing the stream should close the channel
*/
public FileChannelInputStream(FileChannel channel) {
public FileChannelInputStream(FileChannel channel, boolean closeChannel) {
this.channel = channel;
this.closeChannel = closeChannel;
}
@Override
......@@ -53,7 +56,9 @@ public class FileChannelInputStream extends InputStream {
@Override
public void close() throws IOException {
channel.close();
if (closeChannel) {
channel.close();
}
}
}
......@@ -77,7 +77,7 @@ public class FilePathCrypt extends FilePathWrapper {
@Override
public InputStream newInputStream() throws IOException {
return new FileChannelInputStream(open("r"));
return new FileChannelInputStream(open("r"), true);
}
/**
......
......@@ -162,7 +162,7 @@ public class FilePathMem extends FilePath {
public InputStream newInputStream() {
FileMemData obj = getMemoryFile();
FileMem m = new FileMem(obj, true);
return new FileChannelInputStream(m);
return new FileChannelInputStream(m, true);
}
@Override
......
......@@ -162,7 +162,7 @@ public class FilePathNioMem extends FilePath {
public InputStream newInputStream() {
FileNioMemData obj = getMemoryFile();
FileNioMem m = new FileNioMem(obj, true);
return new FileChannelInputStream(m);
return new FileChannelInputStream(m, true);
}
@Override
......
......@@ -171,7 +171,7 @@ public class FilePathZip extends FilePath {
@Override
public InputStream newInputStream() throws IOException {
return new FileChannelInputStream(open("r"));
return new FileChannelInputStream(open("r"), true);
}
@Override
......
......@@ -245,7 +245,7 @@ public class FilePathZip2 extends FilePath {
@Override
public InputStream newInputStream() throws IOException {
return new FileChannelInputStream(open("r"));
return new FileChannelInputStream(open("r"), true);
}
@Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论