Skip to content

Commit

Permalink
Merge pull request #9 from joshmoore/IAE_if_space_in_path#39
Browse files Browse the repository at this point in the history
Fix for issue bcdev#39 when path contains spaces
  • Loading branch information
joshmoore authored Jun 14, 2023
2 parents 8453798 + feb1e53 commit 8742b78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/com/bc/zarr/storage/ZipStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystem;
import java.nio.file.FileSystemAlreadyExistsException;
import java.nio.file.FileSystems;
Expand All @@ -54,7 +56,7 @@ public ZipStore(Path zipFilePath) throws IOException {
if (!Files.exists(zipFilePath)) {
zipParams.put("create", "true");
}
final URI uri = URI.create("jar:file:" + zipFilePath.toUri().getPath());
final URI uri = URI.create("jar:" + zipFilePath.toUri());
zfs = getFileSystem(zipParams, uri);
internalRoot = zfs.getRootDirectories().iterator().next();
}
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/com/bc/zarr/storage/ZipStoreTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ public void tearDown() throws Exception {
}
}


@Test
public void createZipStoreWithSpaceInPath() throws IOException {
Path spaceDir = testDataPath.resolve("folder name");
Files.createDirectories(spaceDir);
Path resolve = spaceDir.resolve("zipped.znap.zip");
store = new ZipStore(resolve);
assertThat(store).isNotNull();
}

@Test
public void createFileSystemStore_withPathString_withoutFS() throws NoSuchFieldException, IllegalAccessException {
//execution
Expand Down

0 comments on commit 8742b78

Please sign in to comment.