@@ -30,6 +30,12 @@ pub(crate) enum CommandError {
3030 #[ error( transparent) ]
3131 Project ( #[ from] icp:: LoadError ) ,
3232
33+ #[ error( transparent) ]
34+ GetEnvCanister ( #[ from] icp:: context:: GetEnvCanisterError ) ,
35+
36+ #[ error( transparent) ]
37+ GetEnvCanisterId ( #[ from] icp:: context:: GetCanisterIdForEnvError ) ,
38+
3339 #[ error( transparent) ]
3440 Unexpected ( #[ from] anyhow:: Error ) ,
3541}
@@ -54,13 +60,6 @@ pub(crate) async fn exec(ctx: &Context, args: &SyncArgs) -> Result<(), CommandEr
5460 false => args. canisters . clone ( ) ,
5561 } ;
5662
57- // Validate all specified canisters exist in project and environment
58- for name in & cnames {
59- ctx. assert_env_contains_canister ( name, & environment_selection)
60- . await
61- . map_err ( |e| anyhow ! ( e) ) ?;
62- }
63-
6463 // Skip doing any work if no canisters are targeted
6564 if cnames. is_empty ( ) {
6665 return Ok ( ( ) ) ;
@@ -73,19 +72,14 @@ pub(crate) async fn exec(ctx: &Context, args: &SyncArgs) -> Result<(), CommandEr
7372 . map_err ( |e| anyhow ! ( e) ) ?;
7473
7574 // Prepare list of canisters with their info for syncing
76- let env_canisters = & env. canisters ;
77- let sync_canisters = try_join_all ( cnames. iter ( ) . map ( |name| {
78- let environment_selection = environment_selection. clone ( ) ;
79- async move {
80- let cid = ctx
81- . get_canister_id_for_env ( name, & environment_selection)
82- . await
83- . map_err ( |e| anyhow ! ( e) ) ?;
84- let ( canister_path, info) = env_canisters
85- . get ( name)
86- . ok_or_else ( || anyhow ! ( "Canister id exists but no canister info" ) ) ?;
87- Ok :: < _ , anyhow:: Error > ( ( cid, canister_path. clone ( ) , info. clone ( ) ) )
88- }
75+ let sync_canisters = try_join_all ( cnames. iter ( ) . map ( |name| async {
76+ let ( canister_path, info) = ctx
77+ . get_canister_and_path_for_env ( name, & environment_selection)
78+ . await ?;
79+ let cid = ctx
80+ . get_canister_id_for_env ( name, & environment_selection)
81+ . await ?;
82+ Ok :: < _ , anyhow:: Error > ( ( cid, canister_path. clone ( ) , info. clone ( ) ) )
8983 } ) )
9084 . await ?;
9185
0 commit comments