Refactor to use let-else chains for artifact scanning
keypair34 committed
Apr 23, 2026 at 06:45 UTC
f33380a83bb657fc190414c16c18af82e076a04d
1 file changed
+16
-18
src/project.rs
+16
-18
@@ -162,10 +162,10 @@ pub fn list_projects() -> Vec<(String, ProjectMeta)> {
162
let repo_name = repo_entry.file_name().to_string_lossy().to_string();
163
let repo_id = format!("{org_name}/{repo_name}");
164
165
- if let Ok(raw) = std::fs::read_to_string(&meta_path) {
166
- if let Ok(meta) = serde_json::from_str::<ProjectMeta>(&raw) {
167
- projects.push((repo_id, meta));
168
- }
165
+ if let Ok(raw) = std::fs::read_to_string(&meta_path)
166
+ && let Ok(meta) = serde_json::from_str::<ProjectMeta>(&raw)
167
+ {
168
+ projects.push((repo_id, meta));
169
}
170
}
171
}
@@ -209,22 +209,21 @@ pub fn scan_project_artifacts(project: &OndeProject) -> Vec<ProjectArtifact> {
209
210
// Check for LoRA adapter
211
let lora_file = run_dir.join("lora_adapter.safetensors");
212
- if lora_file.is_file() {
213
- if let Some(a) = artifact_from_path(&lora_file, &run_name, ArtifactType::LoraAdapter) {
214
- artifacts.push(a);
215
- }
212
+ if lora_file.is_file()
213
+ && let Some(a) = artifact_from_path(&lora_file, &run_name, ArtifactType::LoraAdapter)
214
+ {
215
+ artifacts.push(a);
216
}
217
218
// Check for merged model
219
let merged_dir = run_dir.join("merged");
220
if merged_dir.is_dir() {
221
let merged_safetensors = merged_dir.join("model.safetensors");
222
- if merged_safetensors.is_file() {
223
- if let Some(a) =
222
+ if merged_safetensors.is_file()
223
+ && let Some(a) =
224
artifact_from_path(&merged_safetensors, &run_name, ArtifactType::MergedModel)
225
- {
226
- artifacts.push(a);
227
- }
225
+ {
226
+ artifacts.push(a);
227
}
228
}
229
@@ -232,11 +231,10 @@ pub fn scan_project_artifacts(project: &OndeProject) -> Vec<ProjectArtifact> {
231
if let Ok(files) = std::fs::read_dir(&run_dir) {
232
for file in files.flatten() {
233
let fname = file.file_name().to_string_lossy().to_string();
235
- if fname.ends_with(".gguf") {
236
- if let Some(a) = artifact_from_path(&file.path(), &run_name, ArtifactType::Gguf)
237
- {
238
- artifacts.push(a);
239
- }
234
+ if fname.ends_with(".gguf")
235
+ && let Some(a) = artifact_from_path(&file.path(), &run_name, ArtifactType::Gguf)
236
+ {
237
+ artifacts.push(a);
238
}
239
}
240
}