True if a `try_lock*` error means the lock is currently held by someone else (as opposed to a genuine I/O failure). On Unix a contended non-blocking lock surfaces as `WouldBlock`, but on Windows the OS returns `ERROR_LOCK_VIOLATION` (code 33), which maps to `ErrorKind::Uncategorized` rather than `WouldBlock`. Comparing the raw OS error against `fs2::lock_contended_error()` handles both platforms.
(e: &std::io::Error)
| 28 | /// `ErrorKind::Uncategorized` rather than `WouldBlock`. Comparing the raw OS |
| 29 | /// error against `fs2::lock_contended_error()` handles both platforms. |
| 30 | pub(crate) fn is_lock_contended(e: &std::io::Error) -> bool { |
| 31 | e.kind() == std::io::ErrorKind::WouldBlock |
| 32 | || (e.raw_os_error().is_some() |
| 33 | && e.raw_os_error() == fs2::lock_contended_error().raw_os_error()) |
| 34 | } |
| 35 | |
| 36 | impl Repository { |
| 37 | /// Return the first working-copy file that still contains an unresolved |
no test coverage detected