Package org.apache.tika.plugins
Class ThreadSafeUnzipper
java.lang.Object
org.apache.tika.plugins.ThreadSafeUnzipper
Thread-safe and process-safe plugin unzipper using atomic rename.
This avoids file locking issues on Windows by using a simple strategy:
- Check if destination directory exists with completion marker - if yes, already extracted
- Extract to a temporary directory with a unique name
- Create a completion marker file in the temp directory
- Atomically rename temp dir to final destination
- If rename fails (another process won), clean up temp dir
The completion marker ensures that even if atomic move is not supported, other processes won't attempt to load a partially-moved directory.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidunzipPlugin(Path source) Unzips a plugin zip file to a directory with the same name (minus .zip extension).
-
Constructor Details
-
ThreadSafeUnzipper
public ThreadSafeUnzipper()
-
-
Method Details
-
unzipPlugin
Unzips a plugin zip file to a directory with the same name (minus .zip extension). Safe for concurrent calls from multiple threads or processes. See documentation at the head of this class for how it works.- Parameters:
source- path to the .zip file- Throws:
IOException- if extraction fails
-