Skip to content

Commit 2fd4660

Browse files
authored
fix: cfg disable unix-specific operations (#5326)
Fixes #5311. I think seek-then-read is safe because we own this File. No one else should be relying on its cursor. vortex_io::file::std_file appears to only be used in tests. Signed-off-by: Daniel King <[email protected]>
1 parent d9fb43f commit 2fd4660

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

vortex-io/src/file/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod driver;
66
#[cfg(feature = "object_store")]
77
pub mod object_store;
88
mod read;
9-
#[cfg(not(target_arch = "wasm32"))]
9+
#[cfg(all(unix, not(target_arch = "wasm32")))]
1010
mod std_file;
1111

1212
pub(crate) use driver::*;

vortex-io/src/file/object_store.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

44
use std::io;
5+
#[cfg(unix)]
56
use std::os::unix::fs::FileExt;
67
use std::sync::Arc;
78

@@ -129,10 +130,18 @@ impl ReadSource for ObjectStoreIoSource {
129130
// The read_exact_at call will either fill the entire buffer or return an error,
130131
// ensuring no uninitialized memory is exposed.
131132
unsafe { buffer.set_len(len) };
133+
132134
handle
133135
.spawn_blocking(move || {
134-
file.read_exact_at(&mut buffer, range.start)?;
135-
Ok::<_, io::Error>(buffer)
136+
#[cfg(unix)] {
137+
file.read_exact_at(&mut buffer, range.start)?;
138+
Ok::<_, io::Error>(buffer)
139+
}
140+
#[cfg(not(unix))] {
141+
file.seek(range.start)?;
142+
file.read_exact(&mut buffer)?;
143+
Ok::<_, io::Error>(buffer)
144+
}
136145
})
137146
.await
138147
.map_err(io::Error::other)?

0 commit comments

Comments
 (0)