Skip to content

Commit 0d7cde2

Browse files
f4z3rbrooksmtownsend
authored andcommitted
fix(plugin): uninstall first when installing with --force flag
Relates-to: #84 Signed-off-by: Jakob Beckmann <f4z3r-github@pm.me>
1 parent 6040d04 commit 0d7cde2

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

crates/wash/src/plugin.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,16 @@ pub async fn install_plugin(
344344
let plugin_path = plugins_dir.join(format!("{sanitized_name}.wasm"));
345345

346346
// Check if plugin already exists
347-
if plugin_path.exists() && !options.force {
348-
bail!(
349-
"Plugin '{}' already exists. Use --force option to overwrite",
350-
metadata.name
351-
);
347+
if plugin_path.exists() {
348+
if options.force {
349+
// uninstall first, to really force clean re-install
350+
uninstall_plugin(ctx, &metadata.name).await?;
351+
} else {
352+
bail!(
353+
"Plugin '{}' already exists. Use --force option to overwrite",
354+
metadata.name
355+
);
356+
}
352357
}
353358
// Write plugin to storage
354359
tokio::fs::write(&plugin_path, &component_data)

0 commit comments

Comments
 (0)