Skip to content

Commit 74b27ef

Browse files
committed
Fix for Issue #17. Import target parameter fails when a file extension is provided
1 parent 8149786 commit 74b27ef

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/org/xbib/io/commons/TarSession.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public synchronized void open(Mode mode) throws IOException {
5555
switch (mode) {
5656
case READ:
5757
if (scheme.startsWith("targz")) {
58-
String s = part + ".tar.gz";
58+
String s = (part.endsWith("tar.gz")) ? part : part + ".tar.gz";
5959
File f = new File(s);
6060
if (f.isFile() && f.canRead()) {
6161
this.fin = new FileInputStream(f);
@@ -65,7 +65,7 @@ public synchronized void open(Mode mode) throws IOException {
6565
throw new FileNotFoundException("check existence or access rights: " + s);
6666
}
6767
} else if (scheme.startsWith("tarbz2")) {
68-
String s = part + ".tar.bz2";
68+
String s = (part.endsWith("tar.bz2")) ? part : part + ".tar.bz2";
6969
File f = new File(s);
7070
if (f.isFile() && f.canRead()) {
7171
this.fin = new FileInputStream(f);
@@ -75,7 +75,7 @@ public synchronized void open(Mode mode) throws IOException {
7575
throw new FileNotFoundException("check existence or access rights: " + s);
7676
}
7777
} else if (scheme.startsWith("tarxz")) {
78-
String s = part + ".tar.xz";
78+
String s = (part.endsWith(".tar.xz")) ? part : part + ".tar.xz";
7979
File f = new File(s);
8080
if (f.isFile() && f.canRead()) {
8181
this.fin = new FileInputStream(f);
@@ -85,7 +85,7 @@ public synchronized void open(Mode mode) throws IOException {
8585
throw new FileNotFoundException("check existence or access rights: " + s);
8686
}
8787
} else {
88-
String s = part + ".tar";
88+
String s = (part.endsWith(".tar")) ? part : part + ".tar";
8989
File f = new File(s);
9090
if (f.isFile() && f.canRead()) {
9191
this.fin = new FileInputStream(f);

0 commit comments

Comments
 (0)