Skip to content

Don't rewrite it in Rust. Rewrite the 5% that's slow: profile your app, port the hot functions with your coding agent, prove they behave the same. Python, JS/TS, Ruby, Java, Kotlin, Go, PHP, C/C++, C#, R.

clean: abort in clean --all if disable_all fails

ashp152057ee9247f322e
diff --git a/src/pipeline.rs b/src/pipeline.rs
index 65adf07..66e525a 100644
--- a/src/pipeline.rs
+++ b/src/pipeline.rs
@@ -331,15 +331,9 @@ pub fn clean(root: &Path, all: bool) -> Result<()> {
}
if all {
- match disable_all(root) {
- Ok(disabled) => {
- for id in disabled {
- ui::ok(format!("{} is back to the original code", ui::bold(&id)));
- }
- }
- Err(e) => {
- ui::warn(format!("could not disable all ports cleanly: {e:#}"));
- }
+ let disabled = disable_all(root)?;
+ for id in disabled {
+ ui::ok(format!("{} is back to the original code", ui::bold(&id)));
}
if fast_dir.exists() {
fs::remove_dir_all(&fast_dir).with_context(|| format!("removing {}", fast_dir.display()))?;
@@ -774,4 +768,18 @@ mod tests {
let _ = fs::remove_dir_all(root);
}
+
+ #[test]
+ fn clean_all_aborts_if_disable_fails_preserving_fast_dir() {
+ let (begin, _end) = backend::markers("#", "demo");
+ let text = format!("{begin}\nf = rust\n");
+ let (root, id) = enabled_project("damaged-clean", &text);
+
+ let res = clean(&root, true);
+ assert!(res.is_err(), "clean --all must abort when disable fails");
+ assert!(root.join(".fast").exists(), ".fast must not be deleted if disable fails");
+ assert!(Ctx::open(&root).unwrap().state.ports[&id].enabled);
+
+ let _ = fs::remove_dir_all(root);
+ }
}