Add cleanup of temporary directories after JRE installation#433
Merged
Add cleanup of temporary directories after JRE installation#433
Conversation
…condition When multiple parallel processes (e.g., CI pipelines) run jDeploy concurrently, they all share the same /tmp/njre directory for downloading and extracting JRE archives. This causes ENOENT errors when one process deletes jre.tar.gz while another is reading it, and corrupted archives when writes overlap. Change the temp directory from /tmp/njre to /tmp/njre-<pid> so each process gets its own isolated download path. Also add cleanup of the process-specific temp directory after install completes. Fixes: crowdin/crowdin-cli#1001 https://claude.ai/code/session_01SVe2pisV7FW2bEPTtu5e7Y
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves temporary file management in the JDeploy JRE installation process by ensuring temporary directories are properly cleaned up after use, and making temporary directory names unique per process to avoid conflicts.
Key Changes
cleanupDir()utility function that safely removes directories recursively, ignoring any cleanup errorsnjre-${process.pid}) instead of a static name, preventing conflicts when multiple processes run simultaneously.finally()handlers to bothinstallAdoptOpenJDK()andinstallZulu()functions to ensure temporary directories are cleaned up after installation completes, regardless of success or failureImplementation Details
cleanupDir()function usesfs.rmSync()withrecursive: trueandforce: trueflags to handle directory removal safely.finally()blocks, which execute whether the promise chain succeeds or failshttps://claude.ai/code/session_01SVe2pisV7FW2bEPTtu5e7Y