[ 
https://issues.apache.org/jira/browse/COMPRESS-540?focusedWorklogId=530740&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-530740
 ]

ASF GitHub Bot logged work on COMPRESS-540:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 04/Jan/21 15:59
            Start Date: 04/Jan/21 15:59
    Worklog Time Spent: 10m 
      Work Description: theobisproject commented on a change in pull request 
#113:
URL: https://github.com/apache/commons-compress/pull/113#discussion_r551402409



##########
File path: 
src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
##########
@@ -553,6 +554,23 @@ public TarArchiveEntry(final byte[] headerBuf, final 
ZipEncoding encoding, final
         parseTarHeader(headerBuf, encoding, false, lenient);
     }
 
+    /**
+     * Construct an entry from an archive's header bytes for random access 
tar. File is set to null.
+     * @param headerBuf the header bytes from a tar archive entry.
+     * @param encoding encoding to use for file names.
+     * @param lenient when set to true illegal values for group/userid, mode, 
device numbers and timestamp will be
+     * ignored and the fields set to {@link #UNKNOWN}. When set to false such 
illegal fields cause an exception instead.
+     * @param dataOffset position of the entry data in the random access file.
+     * @since 1.21
+     * @throws IllegalArgumentException if any of the numeric fields have an 
invalid format.
+     * @throws IOException on error.
+     */
+    public TarArchiveEntry(final byte[] headerBuf, final ZipEncoding encoding, 
final boolean lenient,
+            final long dataOffset) throws IOException {
+        this(headerBuf, encoding, lenient);
+        this.dataOffset = dataOffset;
+    }

Review comment:
       It now throws an IAE if the offset is negative. Detecting if the offset 
is larger than the complete file is not possible here. I tested setting the 
offset of an entry to the end of the file. When reading the inputstream there 
is immediately an IOException thrown.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 530740)
    Time Spent: 9h 10m  (was: 9h)

> Random access on Tar archive
> ----------------------------
>
>                 Key: COMPRESS-540
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-540
>             Project: Commons Compress
>          Issue Type: Improvement
>            Reporter: Robin Schimpf
>            Priority: Major
>          Time Spent: 9h 10m
>  Remaining Estimate: 0h
>
> The TarArchiveInputStream only provides sequential access. If only a small 
> amount of files from the archive is needed large amount of data in the input 
> stream needs to be skipped.
> Therefore I was working on a implementation to provide random access to 
> TarFiles equal to the ZipFile api. The basic idea behind the implementation 
> is the following
>  * Random access is backed by a SeekableByteChannel
>  * Read all headers of the tar file and save the place to the data of every 
> header
>  * User can request an input stream for any entry in the archive multiple 
> times



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to