提交 f161e9f5 authored 作者: noelgrandin's avatar noelgrandin

simplify - we don't need to store tempFileDeleter, we can just retrieve it when we need it

上级 0211e92b
...@@ -17,7 +17,6 @@ import org.h2.engine.Constants; ...@@ -17,7 +17,6 @@ import org.h2.engine.Constants;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.security.SecureFileStore; import org.h2.security.SecureFileStore;
import org.h2.store.fs.FileUtils; import org.h2.store.fs.FileUtils;
import org.h2.util.TempFileDeleter;
/** /**
* This class is an abstraction of a random access file. * This class is an abstraction of a random access file.
...@@ -53,7 +52,6 @@ public class FileStore { ...@@ -53,7 +52,6 @@ public class FileStore {
private Reference<?> autoDeleteReference; private Reference<?> autoDeleteReference;
private boolean checkedWriting = true; private boolean checkedWriting = true;
private final String mode; private final String mode;
private final TempFileDeleter tempFileDeleter;
private java.nio.channels.FileLock lock; private java.nio.channels.FileLock lock;
/** /**
...@@ -66,11 +64,6 @@ public class FileStore { ...@@ -66,11 +64,6 @@ public class FileStore {
protected FileStore(DataHandler handler, String name, String mode) { protected FileStore(DataHandler handler, String name, String mode) {
this.handler = handler; this.handler = handler;
this.name = name; this.name = name;
if (handler != null) {
tempFileDeleter = handler.getTempFileDeleter();
} else {
tempFileDeleter = null;
}
try { try {
boolean exists = FileUtils.exists(name); boolean exists = FileUtils.exists(name);
if (exists && !FileUtils.canWrite(name)) { if (exists && !FileUtils.canWrite(name)) {
...@@ -241,7 +234,7 @@ public class FileStore { ...@@ -241,7 +234,7 @@ public class FileStore {
public void closeAndDeleteSilently() { public void closeAndDeleteSilently() {
if (file != null) { if (file != null) {
closeSilently(); closeSilently();
tempFileDeleter.deleteFile(autoDeleteReference, name); handler.getTempFileDeleter().deleteFile(autoDeleteReference, name);
name = null; name = null;
} }
} }
...@@ -419,7 +412,7 @@ public class FileStore { ...@@ -419,7 +412,7 @@ public class FileStore {
*/ */
public void autoDelete() { public void autoDelete() {
if (autoDeleteReference == null) { if (autoDeleteReference == null) {
autoDeleteReference = tempFileDeleter.addFile(name, this); autoDeleteReference = handler.getTempFileDeleter().addFile(name, this);
} }
} }
...@@ -427,7 +420,7 @@ public class FileStore { ...@@ -427,7 +420,7 @@ public class FileStore {
* No longer automatically delete the file once it is no longer in use. * No longer automatically delete the file once it is no longer in use.
*/ */
public void stopAutoDelete() { public void stopAutoDelete() {
tempFileDeleter.stopAutoDelete(autoDeleteReference, name); handler.getTempFileDeleter().stopAutoDelete(autoDeleteReference, name);
autoDeleteReference = null; autoDeleteReference = null;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论