Skip to content

Commit fe9cb6e

Browse files
committed
perf: only try to create directory if parent is not already a directory (isFile -> throws, null -> creates)
Signed-off-by: Caleb Hulbert <cmhulbert@gmail.com>
1 parent 3e6e07c commit fe9cb6e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/main/java/org/janelia/saalfeldlab/n5/FsIoPolicy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ static FileChannel openFileChannel(final Path path, final boolean forWriting) th
4242

4343
if (forWriting) {
4444
final Path parent = path.getParent();
45-
if (parent != null) {
45+
/* if not null and not directory, it will call `createDirectories` but we expect it to throw an IOException */
46+
if (parent != null && !parent.toFile().isDirectory()) {
4647
Files.createDirectories(parent);
4748
}
4849
return FileChannel.open(path, StandardOpenOption.READ, StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);

0 commit comments

Comments
 (0)