You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2020/11/19 13:13:05 UTC

[tika] branch main updated: Modify TikaInputStream (#363)

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

tallison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git


The following commit(s) were added to refs/heads/main by this push:
     new 8edec4d  Modify TikaInputStream (#363)
8edec4d is described below

commit 8edec4d5af6e2848e2b9172e97167c3b73630a56
Author: Lee <55...@users.noreply.github.com>
AuthorDate: Thu Nov 19 21:12:54 2020 +0800

    Modify TikaInputStream (#363)
    
    In method getPath, copy data from InputStream to a temporary file should use current TikaInputStream.
    Otherwise the variable of TikaInputStream `position` will not update.
    There is not meaning if `position` is not real position.
---
 tika-core/src/main/java/org/apache/tika/io/TikaInputStream.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tika-core/src/main/java/org/apache/tika/io/TikaInputStream.java b/tika-core/src/main/java/org/apache/tika/io/TikaInputStream.java
index eb1ea26..deb11e1 100644
--- a/tika-core/src/main/java/org/apache/tika/io/TikaInputStream.java
+++ b/tika-core/src/main/java/org/apache/tika/io/TikaInputStream.java
@@ -677,7 +677,7 @@ public class TikaInputStream extends TaggedInputStream {
             } else {
                 Path tmpFile = tmp.createTempFile();
                 if (maxBytes > -1) {
-                    try (InputStream lookAhead = new LookaheadInputStream(in, maxBytes)) {
+                    try (InputStream lookAhead = new LookaheadInputStream(this, maxBytes)) {
                         Files.copy(lookAhead, tmpFile, REPLACE_EXISTING);
                         if (Files.size(tmpFile) >= maxBytes) {
                             //tmpFile will be cleaned up when this TikaInputStream is closed
@@ -686,7 +686,7 @@ public class TikaInputStream extends TaggedInputStream {
                     }
                 } else {
                     // Spool the entire stream into a temporary file
-                    Files.copy(in, tmpFile, REPLACE_EXISTING);
+                    Files.copy(this, tmpFile, REPLACE_EXISTING);
                 }
                 //successful so far, set tis' path to tmpFile
                 path = tmpFile;