Skip to content

Commit 4c39fd3

Browse files
committed
feat: print path of the file lock in verbose mode
1 parent 4b96b30 commit 4c39fd3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/cargo/util/flock.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::io;
1212
use std::io::{Read, Seek, SeekFrom, Write};
1313
use std::path::{Display, Path, PathBuf};
1414

15+
use crate::core::Verbosity;
1516
use crate::util::errors::CargoResult;
1617
use crate::util::style;
1718
use crate::util::GlobalContext;
@@ -392,14 +393,15 @@ fn acquire(
392393
lock_try: &dyn Fn() -> io::Result<()>,
393394
lock_block: &dyn Fn() -> io::Result<()>,
394395
) -> CargoResult<()> {
395-
if cfg!(debug_assertions) {
396-
// Force borrow to catch invalid borrows outside of contention situations
397-
gctx.shell().verbosity();
398-
}
396+
let verbose = gctx.shell().verbosity() == Verbosity::Verbose;
399397
if try_acquire(path, lock_try)? {
400398
return Ok(());
401399
}
402-
let msg = format!("waiting for file lock on {}", msg);
400+
let msg = if verbose {
401+
format!("waiting for file lock on {} ({})", msg, path.display())
402+
} else {
403+
format!("waiting for file lock on {}", msg)
404+
};
403405
gctx.shell()
404406
.status_with_color("Blocking", &msg, &style::NOTE)?;
405407

0 commit comments

Comments
 (0)