Menu

#20 Extraction: ZIP in RAR problem

15.09-2.01beta
open
rar (1)
5
2016-03-02
2016-02-29
No

Quelle: https://sourceforge.net/p/sevenzipjbind/discussion/757965/thread/e04245f5/?limit=25

Hi, I'm using the 7-Zip-JBinding library to extract archives, and I ran across an unusual problem involving rar files. If the library processes a rar file with three documents in it, they all extract just fine, and if I call IInArchive.getNumberOfItems() for the archive, it returns 3. However, let's say I add a zip file to this rar file, which contains a single file within it. When I try to extract the rar file, IInArchive.getNumberOfItems() returns 1, and the code actually goes into the zip file and extracts the contents of it. It then ignores any other files that were within the rar file.

This only seems to happen with zip files. If I stick a .7z file in the rar file, or another rar file, all of the files are extracted just fine.

Any ideas would be appreciated.

Thanks,
-Bill

  • Affected versions: ab 2.00
  • Tested platforms: Windows 7 64bit
  • 7-zip extraction: Ok

Discussion

  • Boris Brodski

    Boris Brodski - 2016-02-29
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -10,3 +10,7 @@
    
     Thanks,
     -Bill
    +
    +* Affected versions: ab 2.00
    +* Tested platforms: Windows 7 64bit
    +* 7-zip extraction: Ok
    
     
  • Boris Brodski

    Boris Brodski - 2016-03-01

    Unfortunately I couldn't reproduce this bug. In attachement you will find the RAR file I created. I run following code (on Linux)

                randomAccessFile = new RandomAccessFile("testdata/bug/Ticket20-3-txt-files+1-zip.rar", "r");
                inArchive = SevenZip.openInArchive(ArchiveFormat.RAR, new RandomAccessFileInStream(randomAccessFile));
                int numberOfItems = inArchive.getNumberOfItems();
                System.out.println("Items in archive: " + numberOfItems);
                for (int i = 0; i < numberOfItems; i++) {
                    System.out.println("Item #" + i + " " + inArchive.getProperty(i, PropID.PATH) + " (is folder: "
                            + inArchive.getProperty(i, PropID.IS_FOLDER) + ")");
                }
    

    and get the expected result:

    Items in archive: 4
    Item #0 file1.txt (is folder: false)
    Item #1 file2.txt (is folder: false)
    Item #2 file3.txt (is folder: false)
    Item #3 file4.zip (is folder: false)
    

    Could you please run your code with my test RAR archive and see, if it going to crash or not?
    If this not going to help, could you please create a RAR file similar to yours, that does reproduce the problem and send it to me (You may send it directly to my private e-mail address, in case you don't want to make the content public).

     
  • Bill Sterns

    Bill Sterns - 2016-03-01

    Boris,

    I ran the sample code that you provided, and the problem does not show up. However, I did get the problem to occur when null is passed in for the first parameter within SevenZip.openInArchive(). Since my code handles multiple types of archives, I'm passing in null for the archive format so it can be auto-detected.

    -Bill

     
  • Bill Sterns

    Bill Sterns - 2016-03-01

    I verified that the problem does not occur with your rar file, so here's one I've created that can demonstrate the problem. With this file, I get the following output:

    Items in archive: 1
    Item #0 fss4.pdf (is folder: false)

    If I change SevenZip.openInArchive(null, new RandomAccessFileInStream(randomAccessFile)) to SevenZip.openInArchive(ArchiveFormat.RAR, new RandomAccessFileInStream(randomAccessFile)), I get the following correct output:

    Items in archive: 3
    Item #0 fw4.zip (is folder: false)
    Item #1 sample1.txt (is folder: false)
    Item #2 fss4.zip (is folder: false)

     
  • Boris Brodski

    Boris Brodski - 2016-03-02

    Great job, thank you! I will check what's going on here.

     

Log in to post a comment.