You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2019/08/19 20:07:31 UTC

[commons-compress] branch master updated: COMPRESS-231 document how to read 7z multi volume archives

This is an automated email from the ASF dual-hosted git repository.

bodewig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git


The following commit(s) were added to refs/heads/master by this push:
     new 6615be0  COMPRESS-231 document how to read 7z multi volume archives
6615be0 is described below

commit 6615be084bf20b0044fbd8cb8ac869340e1336d9
Author: Stefan Bodewig <bo...@apache.org>
AuthorDate: Mon Aug 19 22:06:49 2019 +0200

    COMPRESS-231 document how to read 7z multi volume archives
---
 src/changes/changes.xml                                   |   6 ++++++
 .../commons/compress/archivers/sevenz/SevenZFile.java     |   5 +++++
 src/site/xdoc/examples.xml                                |   5 ++++-
 src/site/xdoc/limitations.xml                             |   7 ++++---
 .../commons/compress/archivers/sevenz/SevenZFileTest.java |   9 +++++++++
 src/test/resources/bla-multi.7z.001                       | Bin 0 -> 512 bytes
 src/test/resources/bla-multi.7z.002                       | Bin 0 -> 7 bytes
 7 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 02cd688..63dbc58 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -149,6 +149,12 @@ when they are read via ZipArchiveInputStream or ZipFile.
         exception prevents users from thinking they had successfully
         read the contents of the archive.
       </action>
+      <action type="add" date="2019-08-18" issue="COMPRESS-231"
+              due-to="Tim Underwood">
+        Added a <code>MultiReadOnlySeekableByteChannel</code> class
+        that can be used to concatenate the parts of a multi volume 7z
+        archive so that <code>SevenZFile</code> can read them.
+      </action>
     </release>
     <release version="1.18" date="2018-08-16"
              description="Release 1.18">
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
index eba32e3..3580e6d 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
@@ -72,6 +72,11 @@ import org.apache.commons.compress.utils.InputStreamStatistics;
  * contents can be read, but the use of
  * encryption isn't plausibly deniable.
  *
+ * <p>Multi volume archives can be read by concatenating the parts in
+ * correct order - either manually or by using {link
+ * org.apache.commons.compress.utils.MultiReadOnlySeekableByteChannel}
+ * for example.</p>
+ *
  * @NotThreadSafe
  * @since 1.6
  */
diff --git a/src/site/xdoc/examples.xml b/src/site/xdoc/examples.xml
index b2ed464..e50ebd9 100644
--- a/src/site/xdoc/examples.xml
+++ b/src/site/xdoc/examples.xml
@@ -304,7 +304,10 @@ try (OutputStream fo = Files.newOutputStream(Paths.get("my.tar.gz"));
         Deflate are supported - in addition to those reading supports
         AES-256/SHA-256 and DEFLATE64.</p>
 
-        <p>Multipart archives are not supported at all.</p>
+        <p>Writing multipart archives is not supported at
+        all. Multipart archives can be read by concatenating the parts
+        for example by using
+        <code>MultiReadOnlySeekableByteChannel</code>.</p>
 
         <p>7z archives can use multiple compression and encryption
         methods as well as filters combined as a pipeline of methods
diff --git a/src/site/xdoc/limitations.xml b/src/site/xdoc/limitations.xml
index 6d24625..1dbe1f2 100644
--- a/src/site/xdoc/limitations.xml
+++ b/src/site/xdoc/limitations.xml
@@ -59,9 +59,10 @@
          LZMA.</li>
          <li>Several of the "methods" supported by 7z are not
          implemented in Compress.</li>
-         <li>No support for multi-volume archives. It seems multi
-         volume archives can be concatenated and then read by
-         <code>SevenZFile</code>, though.</li>
+         <li>No support for writing multi-volume archives Such
+         archives can be read by simply concatenating the parts, for
+         example by using
+         <code>MultiReadOnlySeekableByteChannel</code>.</li>
          <li>Support for some BCJ filters and the DELTA filter has
          been added with Compress 1.8.  Because of a known bug in
          version 1.4 of the <a
diff --git a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
index dfb81b2..4ce07ee 100644
--- a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
@@ -36,6 +36,7 @@ import org.apache.commons.compress.AbstractTestCase;
 import org.apache.commons.compress.MemoryLimitException;
 import org.apache.commons.compress.PasswordRequiredException;
 import org.apache.commons.compress.utils.IOUtils;
+import org.apache.commons.compress.utils.MultiReadOnlySeekableByteChannel;
 import org.apache.commons.compress.utils.SeekableInMemoryByteChannel;
 import org.junit.Test;
 
@@ -302,6 +303,14 @@ public class SevenZFileTest extends AbstractTestCase {
         }
     }
 
+    @Test
+    public void test7zMultiVolumeUnarchive() throws Exception {
+        try (SevenZFile sevenZFile = new SevenZFile(MultiReadOnlySeekableByteChannel
+            .forFiles(getFile("bla-multi.7z.001"), getFile("bla-multi.7z.002")))) {
+            test7zUnarchive(sevenZFile, SevenZMethod.LZMA2);
+        }
+    }
+
     private void test7zUnarchive(final File f, final SevenZMethod m, final byte[] password) throws Exception {
         try (SevenZFile sevenZFile = new SevenZFile(f, password)) {
             test7zUnarchive(sevenZFile, m);
diff --git a/src/test/resources/bla-multi.7z.001 b/src/test/resources/bla-multi.7z.001
new file mode 100644
index 0000000..2b7a0ec
Binary files /dev/null and b/src/test/resources/bla-multi.7z.001 differ
diff --git a/src/test/resources/bla-multi.7z.002 b/src/test/resources/bla-multi.7z.002
new file mode 100644
index 0000000..27cd097
Binary files /dev/null and b/src/test/resources/bla-multi.7z.002 differ