Skip to content

Commit 265b69b

Browse files
committed
Fix match in io probe for file type in upload_from_file
1 parent fce6199 commit 265b69b

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

src/datasets.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ fn upload_from_file(
169169
api_url: &str,
170170
path: &str,
171171
) -> (String, &'static str) {
172-
let f = match std::fs::File::open(path) {
172+
let mut f = match std::fs::File::open(path) {
173173
Ok(f) => f,
174174
Err(e) => {
175175
eprintln!("error opening file '{path}': {e}");
@@ -180,10 +180,7 @@ fn upload_from_file(
180180
let ft = detect_from_path(path).unwrap_or_else(|| {
181181
use std::io::Read;
182182
let mut probe = [0u8; 512];
183-
let n = { use std::io::Read; f.read(&mut probe).unwrap_or(0) };
184-
Ok(mut f2) => f2.read(&mut probe).unwrap_or(0),
185-
Err(_) => 0,
186-
};
183+
let n = f.read(&mut probe).unwrap_or(0);
187184
detect_from_bytes(&probe[..n])
188185
});
189186

0 commit comments

Comments
 (0)