diff --git a/backend/canisters/group_index/impl/src/updates/add_local_group_index_canister.rs b/backend/canisters/group_index/impl/src/updates/add_local_group_index_canister.rs index 5568908356..36a29ffd7b 100644 --- a/backend/canisters/group_index/impl/src/updates/add_local_group_index_canister.rs +++ b/backend/canisters/group_index/impl/src/updates/add_local_group_index_canister.rs @@ -18,10 +18,14 @@ async fn add_local_group_index_canister(args: Args) -> Response { let wasm_version = result.canister_wasm.version; if let Err(error) = set_controllers(args.canister_id, vec![result.this_canister_id]).await { - InternalError(format!("Failed to set controller: {error:?}")) - } else if let Err(error) = install_basic(args.canister_id, result.canister_wasm, result.init_args).await { - InternalError(format!("Failed to install canister: {error:?}")) - } else if let Err(error) = upgrade_group_wasm_in_local_group_index( + return InternalError(format!("Failed to set controller: {error:?}")); + } + if let Err(error) = install_basic(args.canister_id, result.canister_wasm, result.init_args).await { + if !error.1.contains("canister is not empty") { + return InternalError(format!("Failed to install canister: {error:?}")); + } + } + if let Err(error) = upgrade_group_wasm_in_local_group_index( args.canister_id, &result.group_canister_wasm, result.group_canister_wasm_hash, diff --git a/backend/canisters/user_index/impl/src/updates/add_local_user_index_canister.rs b/backend/canisters/user_index/impl/src/updates/add_local_user_index_canister.rs index 70a9cca58f..2a99a3ff37 100644 --- a/backend/canisters/user_index/impl/src/updates/add_local_user_index_canister.rs +++ b/backend/canisters/user_index/impl/src/updates/add_local_user_index_canister.rs @@ -18,10 +18,14 @@ async fn add_local_user_index_canister(args: Args) -> Response { let wasm_version = result.canister_wasm.version; if let Err(error) = set_controllers(args.canister_id, vec![result.this_canister_id]).await { - InternalError(format!("Failed to set controller: {error:?}")) - } else if let Err(error) = install_basic(args.canister_id, result.canister_wasm, result.init_args).await { - InternalError(format!("Failed to install canister: {error:?}")) - } else if let Err(error) = upgrade_user_wasm_in_local_user_index( + return InternalError(format!("Failed to set controller: {error:?}")); + } + if let Err(error) = install_basic(args.canister_id, result.canister_wasm, result.init_args).await { + if !error.1.contains("canister is not empty") { + return InternalError(format!("Failed to install canister: {error:?}")); + } + } + if let Err(error) = upgrade_user_wasm_in_local_user_index( args.canister_id, &result.user_canister_wasm, result.user_canister_wasm_hash,