diff --git a/src/api/sync.rs b/src/api/sync.rs index 0ba408a..1819f13 100644 --- a/src/api/sync.rs +++ b/src/api/sync.rs @@ -75,7 +75,6 @@ struct Handle { impl Drop for Handle { fn drop(&mut self) { - println!("Released lock on {:?}", std::thread::current().id()); unlock(&self.file); } } @@ -95,7 +94,6 @@ fn lock_file(mut path: PathBuf) -> Result { if res != 0 { Err(ApiError::LockAcquisition(path)) } else { - println!("Acquired lock on {:?}", std::thread::current().id()); Ok(Handle { file }) } } @@ -121,7 +119,6 @@ mod windows { use windows_sys::Win32::Storage::FileSystem::{ LockFileEx, UnlockFile, LOCKFILE_EXCLUSIVE_LOCK, LOCKFILE_FAIL_IMMEDIATELY, }; - use windows_sys::Win32::System::SystemServices::MAXDWORD; pub(crate) fn lock(file: &std::fs::File) -> i32 { unsafe { @@ -131,8 +128,8 @@ mod windows { file.as_raw_handle() as HANDLE, flags, 0, - MAXDWORD, - MAXDWORD, + !0, + !0, &mut overlapped, ); 1 - res diff --git a/src/api/tokio.rs b/src/api/tokio.rs index 5015969..69070a2 100644 --- a/src/api/tokio.rs +++ b/src/api/tokio.rs @@ -113,7 +113,6 @@ mod windows { use windows_sys::Win32::Storage::FileSystem::{ LockFileEx, UnlockFile, LOCKFILE_EXCLUSIVE_LOCK, LOCKFILE_FAIL_IMMEDIATELY, }; - use windows_sys::Win32::System::SystemServices::MAXDWORD; pub(crate) fn lock(file: &tokio::fs::File) -> i32 { unsafe { @@ -123,8 +122,8 @@ mod windows { file.as_raw_handle() as HANDLE, flags, 0, - MAXDWORD, - MAXDWORD, + !0, + !0, &mut overlapped, ); 1 - res @@ -859,7 +858,7 @@ impl ApiRepo { let blob_path = cache.blob_path(&metadata.etag); std::fs::create_dir_all(blob_path.parent().unwrap())?; - let lock = lock_file(blob_path.clone()).await.unwrap(); + let lock = lock_file(blob_path.clone()).await?; progress.init(metadata.size, filename).await; let mut tmp_path = blob_path.clone(); tmp_path.set_extension(EXTENSION);