Skip to content

Commit 73ecb40

Browse files
committed
fix: Interpret PermissionDenied as reason to retry on lock acquisition failure. (#386)
Evidence from CI suggests that on windows 'AlreadyExists' isn't the common error code. Instead, maybe due to racyness, it can also emit PermissionDenied errors which we now handle specifically.
1 parent 339e7a9 commit 73ecb40

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

git-lock/src/acquire.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ fn lock_with_mode<T>(
121121
attempts += 1;
122122
match try_lock(&lock_path, directory, cleanup.clone()) {
123123
Ok(v) => return Ok((lock_path, v)),
124+
#[cfg(windows)]
125+
Err(err) if err.kind() == AlreadyExists || err.kind() == PermissionDenied => {
126+
std::thread::sleep(wait);
127+
continue;
128+
}
129+
#[cfg(not(windows))]
124130
Err(err) if err.kind() == AlreadyExists => {
125131
std::thread::sleep(wait);
126132
continue;

0 commit comments

Comments
 (0)