mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
[PR #584] [MERGED] Fix race condition when concurrently downloading packages #628
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/584
Author: @bioball
Created: 7/17/2024
Status: ✅ Merged
Merged: 7/18/2024
Merged by: @bioball
Base:
main← Head:fix-package-download-race-cond📝 Commits (2)
dcdea3cFix race condition when concurrently downloading packagese3d240aAddress PR comments📊 Changes
2 files changed (+16 additions, -10 deletions)
View changed files
📝
pkl-core/src/main/java/org/pkl/core/packages/PackageResolvers.java(+10 -5)📝
pkl-core/src/test/kotlin/org/pkl/core/packages/PackageResolversTest.kt(+6 -5)📄 Description
This fixes a possible race condition where multiple processes download the same package into the same temp dir.
The issue here is that we are using the same filename when creating these temp files. Because of this, two concurrent processes can possibly run into
FileAlreadyExistsExceptionwhen attempting to create the temporary file.This fixes the problem by using the
Files#createTempFileAPI to ensure that these filenames are unique.Closes https://github.com/apple/pkl/issues/583
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.