Alberto1202 / jtar

Automatically exported from code.google.com/p/jtar
0 stars 0 forks source link

Empty subdirectory problem #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Taring directory with an empty subdirectory gives an exception:

java.io.IOException: The current entry[testdir/empty/] of size[40] has not been 
fully written.
    at org.xeustechnologies.jtar.TarOutputStream.closeCurrentEntry(TarOutputStream.java:109)
    at org.xeustechnologies.jtar.TarOutputStream.putNextEntry(TarOutputStream.java:91)

It happens when using the code from JTarTest.java. 

jtar-1.0.4 on archlinux

Original issue reported on code.google.com by konr4...@gmail.com on 5 Feb 2012 at 10:03

GoogleCodeExporter commented 9 years ago
Adding padding manually seems to solve this issue. I suggest changing 
JTarTest.java. 

Original comment by konr4...@gmail.com on 5 Feb 2012 at 10:49

GoogleCodeExporter commented 9 years ago

Original comment by xeus....@gmail.com on 16 Feb 2012 at 3:52

GoogleCodeExporter commented 9 years ago

Original comment by xeus....@gmail.com on 16 Feb 2012 at 3:52

GoogleCodeExporter commented 9 years ago
Padding is not a good idea. This actually breaks the Solaris tar - it stops on 
directory entries containing zeros. The root problem seems to be that 
File.length() behaves different on Windows (returns 0)/Unix (returns a size). A 
Tar directory entry does not need any data/size - so the correct fix imho is to 
change TarEntry.extractTarHeader() to something like this:

...
 if(file.isDirectory()) {
...
      header.size = 0;

    } else {
...
      header.size = file.length();
    }

Original comment by holger.p...@gmail.com on 16 Apr 2012 at 7:03

GoogleCodeExporter commented 9 years ago

Original comment by xeus....@gmail.com on 1 May 2012 at 9:13