Skip to content

Add cleanup of temporary directories after JRE installation#433

Merged
shannah merged 1 commit intomasterfrom
claude/investigate-crowdin-issue-1001-affqz
Mar 12, 2026
Merged

Add cleanup of temporary directories after JRE installation#433
shannah merged 1 commit intomasterfrom
claude/investigate-crowdin-issue-1001-affqz

Conversation

@shannah
Copy link
Copy Markdown
Owner

@shannah shannah commented Mar 12, 2026

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

  • Added cleanupDir() utility function that safely removes directories recursively, ignoring any cleanup errors
  • Modified temporary directory paths to include the process ID (njre-${process.pid}) instead of a static name, preventing conflicts when multiple processes run simultaneously
  • Added .finally() handlers to both installAdoptOpenJDK() and installZulu() functions to ensure temporary directories are cleaned up after installation completes, regardless of success or failure

Implementation Details

  • The cleanupDir() function uses fs.rmSync() with recursive: true and force: true flags to handle directory removal safely
  • Errors during cleanup are silently ignored to prevent installation failures due to cleanup issues
  • The process ID suffix ensures each installation attempt uses an isolated temporary directory, improving reliability in concurrent scenarios
  • Cleanup is guaranteed via .finally() blocks, which execute whether the promise chain succeeds or fails

https://claude.ai/code/session_01SVe2pisV7FW2bEPTtu5e7Y

…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
@shannah shannah merged commit 6f6aa0c into master Mar 12, 2026
16 checks passed
@shannah shannah deleted the claude/investigate-crowdin-issue-1001-affqz branch March 12, 2026 21:08
shannah pushed a commit that referenced this pull request Mar 13, 2026
shannah pushed a commit that referenced this pull request Mar 13, 2026
shannah pushed a commit that referenced this pull request Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants