@@ -45,6 +45,13 @@ impl<M: Memory + Clone> Storage<M> {
4545 id_range_lo, anchor_count
4646 ) ;
4747 ic_cdk:: println!( "ERROR: {}" , err) ;
48+ RECOVERY_PHRASE_MIGRATION_ERRORS . with_borrow_mut ( |all_errors| {
49+ all_errors. push ( err) ;
50+ } ) ;
51+
52+ // Ensure that migration is not retried endlessly.
53+ ic_cdk:: println!( "Recovery phrase migration CANCELED." ) ;
54+ RECOVERY_PHRASE_MIGRATION_BATCH_ID . replace ( u64:: MAX ) ;
4855 return ;
4956 } ;
5057
@@ -69,6 +76,10 @@ impl<M: Memory + Clone> Storage<M> {
6976
7077 let mut errors = vec ! [ ] ;
7178
79+ // This condition is used to terminate the migration in the unlikely event that *all*
80+ // anchors within this entire batch failed to migrate.
81+ let mut batch_did_not_fail_completely = false ;
82+
7283 // This is where the index migration happens. For each anchor in the batch, read it
7384 // from storage and write it back, which updates the indices.
7485 for anchor_number in begin..=end {
@@ -86,17 +97,16 @@ impl<M: Memory + Clone> Storage<M> {
8697 Err ( err) => {
8798 let err = format ! ( "w#{}:{:?}" , anchor_number, err) ;
8899 errors. push ( err) ;
100+ continue ;
89101 }
90102 }
103+
104+ batch_did_not_fail_completely = true ;
91105 }
92106
93107 // Whether more batches are to be migrated.
94108 let has_more_work = end < last_anchor_id;
95109
96- // This condition is used to terminate the migration in the unlikely event that *all*
97- // anchors within this entire batch failed to migrate.
98- let batch_did_not_fail_completely = errors. len ( ) < batch_size as usize ;
99-
100110 if errors. is_empty ( ) {
101111 ic_cdk:: println!( "Successfully migrated batch {}..{}" , begin, end) ;
102112 } else {
0 commit comments