Skip to content

Commit ca4e67d

Browse files
authored
Fix windows (#87)
- **Add windows compile check** - **Fix windows** Resolves: #86
1 parent 8a99ad8 commit ca4e67d

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

.github/workflows/rust-ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ name: CI
1010
jobs:
1111
lint:
1212
name: Lint
13-
runs-on: ubuntu-22.04
13+
strategy:
14+
matrix:
15+
os:
16+
- ubuntu-22.04
17+
- windows-2022
18+
runs-on: ${{ matrix.os }}
1419
steps:
1520
- uses: actions/checkout@v4
1621
- uses: dtolnay/rust-toolchain@stable
@@ -36,7 +41,6 @@ jobs:
3641
matrix:
3742
os:
3843
- ubuntu-22.04
39-
#- windows-2022
4044
features: ["--features git", "--features sparse", "--features local-builder,sparse"]
4145
runs-on: ${{ matrix.os }}
4246
steps:

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
<!-- next-header -->
1111
## [Unreleased] - ReleaseDate
12+
### Fixed
13+
- [PR#87](https://github.com/EmbarkStudios/tame-index/pull/87) resolved [#86](https://github.com/EmbarkStudios/tame-index/issues/86) by adding a missing `unsafe` that caused the Windows target to fail to compile.
14+
1215
## [0.20.0] - 2025-04-07
1316
### Fixed
1417
- [PR#85](https://github.com/EmbarkStudios/tame-index/pull/85) updated gix -> 0.71 and tokio to 1.44.2, addressing [RUSTSEC-2025-0021](https://rustsec.org/advisories/RUSTSEC-2025-0021) and [RUSTSEC-2025-0023](https://rustsec.org/advisories/RUSTSEC-2025-0023).

src/utils/flock/win_bindings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
clippy::upper_case_acronyms
77
)]
88
#[link(name = "kernel32")]
9-
extern "system" {
9+
unsafe extern "system" {
1010
#[link_name = "CloseHandle"]
1111
pub fn close_handle(object: Handle) -> Bool;
1212
#[link_name = "CreateEventA"]

src/utils/flock/windows.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ fn flock(file: &File, flags: u32, timeout: Option<Duration>) -> Result {
7575
{
7676
let err = Error::last_os_error();
7777

78-
if err
79-
.raw_os_error()
80-
.map_or(false, |x| x == Win32Error::ErrorIoPending as i32)
81-
{
78+
if err.raw_os_error() == Some(Win32Error::ErrorIoPending as i32) {
8279
let timeout = timeout.map_or(0, |dur| {
8380
let millis = dur.as_millis();
8481
if millis >= Infinite as u128 {
@@ -120,19 +117,17 @@ pub(super) fn unlock(file: &File) -> Result {
120117

121118
#[inline]
122119
pub(super) fn is_contended(err: &Error) -> bool {
123-
err.raw_os_error()
124-
.map_or(false, |x| x == Win32Error::ErrorLockViolation as i32)
120+
err.raw_os_error() == Some(Win32Error::ErrorLockViolation as i32)
125121
}
126122

127123
#[inline]
128124
pub(super) fn is_unsupported(err: &Error) -> bool {
129-
err.raw_os_error()
130-
.map_or(false, |x| x == Win32Error::ErrorInvalidFunction as i32)
125+
err.raw_os_error() == Some(Win32Error::ErrorInvalidFunction as i32)
131126
}
132127

133128
#[inline]
134129
pub(super) fn is_timed_out(err: &Error) -> bool {
135-
err.raw_os_error().map_or(false, |x| {
130+
err.raw_os_error().is_some_and(|x| {
136131
x == Win32Error::WaitTimeout as i32 || x == Win32Error::WaitIoCompletion as i32
137132
})
138133
}

0 commit comments

Comments
 (0)