Skip to content

Commit 5f1f392

Browse files
committed
Refactor file handling and dataset file listing logic
Improves file picker logic to allow single file selection from multiple paths and refactors dataset file listing to remove redundant empty checks. This streamlines error handling and simplifies code paths.
1 parent 6e4f590 commit 5f1f392

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

src/cli/file_picker.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,11 @@ impl Into<UploadFile> for FilePickerResult {
9999
fn into(self) -> UploadFile {
100100
match self {
101101
FilePickerResult::Single(path) => UploadFile::from(path),
102-
FilePickerResult::Multiple(_) => {
103-
panic!("Multiple files are not supported for this operation.");
102+
FilePickerResult::Multiple(paths) => {
103+
if paths.len() > 1 {
104+
panic!("Multiple files are not supported for this operation.");
105+
}
106+
UploadFile::from(paths[0].clone())
104107
}
105108
}
106109
}

src/native_api/dataset/listfiles.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,8 @@ pub async fn list_dataset_files(
5959
.ok_or("No data found in dataset metadata".to_string())?;
6060

6161
let files = match dataset.latest_version {
62-
Some(latest_version) => {
63-
if latest_version.files.is_empty() {
64-
return Err("No files found in dataset".to_string());
65-
}
66-
latest_version.files
67-
}
68-
None => {
69-
if dataset.files.is_empty() {
70-
return Err("No files found in dataset".to_string());
71-
}
72-
dataset.files
73-
}
62+
Some(latest_version) => latest_version.files,
63+
None => dataset.files,
7464
};
7565

7666
let files = files

0 commit comments

Comments
 (0)