revert extraction of the try_lock fn to ret back cross-comp support
@@ -327,7 +327,13 @@ impl ConfigBuilder {
Ok(file) => {
#[cfg(any(windows, target_os = "linux", target_os = "macos"))]
{
- if let Err(e) = Self::try_lock(&file, self.read_only) {
+ let try_lock = if self.read_only {
+ file.try_lock_shared()
+ } else {
+ file.try_lock_exclusive()
+ };
+
+ if let Err(e) = try_lock {
return Err(Error::Io(io::Error::new(
io::ErrorKind::Other,
format!("could not acquire appropriate file lock on {:?}: {:?}", path, e),
@@ -341,14 +347,6 @@ impl ConfigBuilder {
}
}
- fn try_lock(file: &fs::File, read_only: bool) -> io::Result<()> {
- if read_only {
- file.try_lock_shared()
- } else {
- file.try_lock_exclusive()
- }
- }
-
fn verify_config_changes_ok(&self) -> Result<()> {
match self.read_config() {
Ok(Some(old)) => {
