Skip to content

Commit

Permalink
error out deployCanister when it's already transferred
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyan-dfinity committed Aug 30, 2024
1 parent 9927891 commit f236631
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion script/deploy_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function build_frontend(name) {
function deploy_frontend(dist) {
let expired = ite(exist(frontend_info), is_expired(frontend_info, frontend_init?.canister_time_to_live), true);
let info = ite(exist(frontend_info), opt frontend_info, null);
if expired {
if expired { // TODO: check it is also not transferred
"Frontend caniter expired, fetching a new one...";
let new_info = call Frontend.deployCanister(info, null);
} else {
Expand Down
13 changes: 10 additions & 3 deletions service/pool/Main.mo
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ shared (creator) actor class Self(opt_params : ?Types.InitParams) = this {
await IC.update_settings { canister_id = info.id; settings };
statsByOrigin.addCanister({ origin = "external"; tags = [] });
} else {
stats := Logs.updateStats(stats, #mismatch);
throw Error.reject "Cannot find canister";
};
};
Expand All @@ -166,6 +167,7 @@ shared (creator) actor class Self(opt_params : ?Types.InitParams) = this {
throw Error.reject "Only called by controller";
};
if (pool.findId(args.canister_id)) {
stats := Logs.updateStats(stats, #mismatch);
throw Error.reject "Canister is still solely controlled by the playground";
};
await IC.install_code args;
Expand All @@ -180,10 +182,15 @@ shared (creator) actor class Self(opt_params : ?Types.InitParams) = this {
let (info, mode) = switch (opt_info) {
case null { await* getExpiredCanisterInfo(origin) };
case (?info) {
if (not pool.find info) {
await* getExpiredCanisterInfo(origin)
} else {
if (pool.find info) {
(info, #upgrade)
} else {
if (pool.findId(info.id)) {
await* getExpiredCanisterInfo(origin)
} else {
stats := Logs.updateStats(stats, #mismatch);
throw Error.reject "Cannot find canister";
};
};
};
};
Expand Down

0 comments on commit f236631

Please sign in to comment.