From 2e77dc148bb75d8c2e7eb2f01c62473c6da02b2a Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Mon, 18 Dec 2023 09:47:08 +0800 Subject: [PATCH] fix(vendor): use mutate exclusive lock when vendoring Signed-off-by: hi-rustin --- src/cargo/ops/vendor.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cargo/ops/vendor.rs b/src/cargo/ops/vendor.rs index cad7fc5d170..6733656dcec 100644 --- a/src/cargo/ops/vendor.rs +++ b/src/cargo/ops/vendor.rs @@ -4,6 +4,7 @@ use crate::core::{GitReference, Package, Workspace}; use crate::ops; use crate::sources::path::PathSource; use crate::sources::CRATES_IO_REGISTRY; +use crate::util::cache_lock::CacheLockMode; use crate::util::{try_canonicalize, CargoResult, Config}; use anyhow::{bail, Context as _}; use cargo_util::{paths, Sha256}; @@ -31,6 +32,7 @@ pub fn vendor(ws: &Workspace<'_>, opts: &VendorOptions<'_>) -> CargoResult<()> { extra_workspaces.push(ws); } let workspaces = extra_workspaces.iter().chain(Some(ws)).collect::>(); + let _lock = config.acquire_package_cache_lock(CacheLockMode::MutateExclusive)?; let vendor_config = sync(config, &workspaces, opts).with_context(|| "failed to sync")?; if config.shell().verbosity() != Verbosity::Quiet {