Skip to content

Commit 60c23f2

Browse files
shenxianpeng2bndy5
authored andcommitted
fix: lock lib/clang while installing resource headers
Binaries of different versions in one folder share lib/clang and its staging folder, and their downloads hold different locks.
1 parent 3300cc3 commit 60c23f2

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎clang-tools-manager/src/downloader/resource_headers.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use flate2::read::GzDecoder;
1414
use semver::Version;
1515
use zip::{ZipArchive, result::ZipError};
1616

17-
use crate::utils::normalize_path;
17+
use crate::utils::{lock_path, normalize_path};
1818

1919
/// Errors that occur while installing clang's resource headers.
2020
#[derive(Debug, thiserror::Error)]
@@ -94,6 +94,9 @@ fn install_staged(
9494
archive: &Path,
9595
extract: impl FnOnce(&Path) -> Result<bool, ResourceHeadersError>,
9696
) -> Result<(), ResourceHeadersError> {
97+
// Binaries of different versions in one folder share `lib_clang` and the staging folder.
98+
// The lock is released when dropped (at return).
99+
let _lock = lock_path(lib_clang)?;
97100
let staging = lib_clang.with_file_name("clang.partial");
98101
if staging.exists() {
99102
// left over from an extraction that was interrupted

0 commit comments

Comments
 (0)