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

Split file system: truncating a file now deletes the parts in reverse order, so…

Split file system: truncating a file now deletes the parts in reverse order, so that the file list is consistent if the process is interrupted while truncating.
上级 002074b0
......@@ -17,7 +17,9 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>The H2 JDBC client can now be used in an unsigned Applet.
<ul><li>Split file system: truncating a file now deletes the parts in reverse order,
so that the file list is consistent if the process is interrupted while truncating.
</li><li>The H2 JDBC client can now be used in an unsigned Applet.
The problem was that System.getProperty throws a SecurityException, which is now ignored.
</li><li>The condition "in(select ...)" did not work correctly if the subquery
could not be converted to a "distinct" query, as in:
......
......@@ -96,25 +96,31 @@ public class FileObjectSplit implements FileObject {
FileObject[] newList = new FileObject[newFileCount];
int max = Math.max(newFileCount, list.length);
long remaining = newLength;
// delete backwards, so that truncating is somewhat transactional
for (int i = list.length - 1; i >= newFileCount; i--) {
// verify the file is writable
list[i].setFileLength(0);
list[i].close();
try {
IOUtils.delete(list[i].getName());
} catch (DbException e) {
throw DbException.convertToIOException(e);
}
}
for (int i = 0; i < max; i++) {
long size = Math.min(remaining, maxLength);
remaining -= size;
long fileSize = Math.min(remaining, maxLength);
remaining -= fileSize;
if (i >= newFileCount) {
list[i].close();
try {
IOUtils.delete(list[i].getName());
} catch (DbException e) {
throw DbException.convertToIOException(e);
}
// already closed and deleted
} else if (i >= list.length) {
String fileName = FileSystemSplit.getFileName(name, i);
FileObject o = FileSystem.getInstance(fileName).openFileObject(fileName, mode);
o.setFileLength(size);
o.setFileLength(fileSize);
newList[i] = o;
} else {
FileObject o = list[i];
if (o.length() != size) {
o.setFileLength(size);
if (o.length() != fileSize) {
o.setFileLength(fileSize);
}
newList[i] = list[i];
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论