Skip to content

Commit 9372539

Browse files
committed
refactor(context): clearer fetch_context exhaustiveness; drop no-op mkdir
Replace unreachable Err arms with explicit panic message if fetch_context ever returns a non-404 error. Remove create_dir_all on pull (path is always cwd + single filename segment).
1 parent 773fdf3 commit 9372539

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

src/context.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pub fn show(workspace_id: &str, name: &str) {
173173
);
174174
std::process::exit(1);
175175
}
176-
Err(_) => unreachable!(),
176+
Err(status) => panic!("unexpected error status from fetch_context: {status}"),
177177
}
178178
}
179179

@@ -203,7 +203,7 @@ pub fn pull(workspace_id: &str, name: &str, force: bool, dry_run: bool) {
203203
);
204204
std::process::exit(1);
205205
}
206-
Err(_) => unreachable!(),
206+
Err(status) => panic!("unexpected error status from fetch_context: {status}"),
207207
};
208208

209209
let n_chars = ctx.content.chars().count();
@@ -215,13 +215,6 @@ pub fn pull(workspace_id: &str, name: &str, force: bool, dry_run: bool) {
215215
return;
216216
}
217217

218-
if let Some(parent) = path.parent() {
219-
if let Err(e) = fs::create_dir_all(parent) {
220-
eprintln!("error: could not create directory {}: {e}", parent.display());
221-
std::process::exit(1);
222-
}
223-
}
224-
225218
let mut f = fs::File::create(&path).unwrap_or_else(|e| {
226219
eprintln!("error: could not create {}: {e}", path.display());
227220
std::process::exit(1);

0 commit comments

Comments
 (0)