Skip to content

Commit

Permalink
Handle retry attempts when adding a new LocalUser/GroupIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles committed Dec 19, 2024
1 parent 6819115 commit 32743c5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 32743c5

Please sign in to comment.