Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.janelia.saalfeldlab.n5;

import org.apache.commons.io.input.ProxyInputStream;
import org.janelia.saalfeldlab.n5.readdata.ReadData;
import org.janelia.saalfeldlab.n5.readdata.VolatileReadData;

import java.io.*;

Expand All @@ -23,7 +25,15 @@ public Reader newReader() throws N5Exception.N5IOException {

@Override
public InputStream newInputStream() throws N5Exception.N5IOException {
return kva.createReadData(key).inputStream();

VolatileReadData volatileReadData = kva.createReadData(key);
return new ProxyInputStream(volatileReadData.inputStream()) {
@Override
public void close() throws IOException {
volatileReadData.close();
super.close();
}
};
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/janelia/saalfeldlab/n5/FsIoPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public VolatileReadData read(String key) throws IOException {
@Override
public void delete(final String key) throws IOException {
final Path path = Paths.get(key);
if (!Files.isRegularFile(path))
Files.delete(path);
try (LockedFileChannel ignore = FILE_LOCK_MANAGER.lockForWriting(path)) {
Files.delete(path);
}
Expand Down