This is an automated email from the ASF dual-hosted git repository.
tilman pushed a commit to branch branch_3x
in repository https://gitbox.apache.org/repos/asf/tika.git
The following commit(s) were added to refs/heads/branch_3x by this push:
new a7b934143 TIKA-4538: AZBlobFetcher always throws
FileAlreadyExistsException (#2383)
a7b934143 is described below
commit a7b93414360dac99968c0f24ea52c3f2889ef4c7
Author: Matthew Dutton <[email protected]>
AuthorDate: Fri Oct 31 14:30:19 2025 -0400
TIKA-4538: AZBlobFetcher always throws FileAlreadyExistsException (#2383)
REF: https://issues.apache.org/jira/browse/TIKA-4538
When hosting Tika on Windows, calling the /tika/* endpoints with
enableUnsecureFeatures=true and using AZBlobFetcher, the AZBlobFetcher
throws a
FileAlreadyExistsException exception.
The AZBlobFetcher uses TemporaryResources.createTempFile() which uses
java.nio.file.Files.createTempFile to create the temp file. This function
does
not just generate a new, unique name but also creates the actual file.
REF:
https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#createTempFile-java.nio.file.Path-java.lang.String-java.lang.String-java.nio.file.attribute.FileAttribute...-
When AZBlobFetcher calls BlobClient.downloadToFile(string), it throws an
exception for the existing file.
This changes to use BlobClient.downloadToFile(string,bool overwrite=true) to
account for the existing file.
REF:
https://javadoc.io/static/com.azure/azure-storage-blob/12.10.1/com/azure/storage/blob/specialized/BlobClientBase.html#downloadToFile-java.lang.String-
---
.../main/java/org/apache/tika/pipes/fetcher/azblob/AZBlobFetcher.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git
a/tika-pipes/tika-fetchers/tika-fetcher-az-blob/src/main/java/org/apache/tika/pipes/fetcher/azblob/AZBlobFetcher.java
b/tika-pipes/tika-fetchers/tika-fetcher-az-blob/src/main/java/org/apache/tika/pipes/fetcher/azblob/AZBlobFetcher.java
index 0dc05a2d5..31255dc4d 100644
---
a/tika-pipes/tika-fetchers/tika-fetcher-az-blob/src/main/java/org/apache/tika/pipes/fetcher/azblob/AZBlobFetcher.java
+++
b/tika-pipes/tika-fetchers/tika-fetcher-az-blob/src/main/java/org/apache/tika/pipes/fetcher/azblob/AZBlobFetcher.java
@@ -103,7 +103,7 @@ public class AZBlobFetcher extends AbstractFetcher
implements Initializable {
long start = System.currentTimeMillis();
TemporaryResources tmpResources = new TemporaryResources();
Path tmp = tmpResources.createTempFile();
- blobClient.downloadToFile(tmp.toRealPath().toString());
+ blobClient.downloadToFile(tmp.toRealPath().toString(), true);
TikaInputStream tis = TikaInputStream.get(tmp, metadata,
tmpResources);
long elapsed = System.currentTimeMillis() - start;
LOGGER.debug("took {} ms to copy to local tmp file", elapsed);