@@ -121,7 +121,7 @@ struct CopyState {
121121}
122122
123123impl CopyState {
124- fn new (
124+ async fn new (
125125 conn : & mut PgConnection ,
126126 primary : Primary ,
127127 src : Arc < Layout > ,
@@ -162,22 +162,22 @@ impl CopyState {
162162 src. site. id
163163 ) ) ;
164164 }
165- Self :: load ( conn, primary, src, dst, target_block)
165+ Self :: load ( conn, primary, src, dst, target_block) . await
166166 }
167- None => Self :: create ( conn, primary. cheap_clone ( ) , src, dst, target_block) ,
167+ None => Self :: create ( conn, primary. cheap_clone ( ) , src, dst, target_block) . await ,
168168 } ?;
169169
170170 Ok ( state)
171171 }
172172
173- fn load (
173+ async fn load (
174174 conn : & mut PgConnection ,
175175 primary : Primary ,
176176 src : Arc < Layout > ,
177177 dst : Arc < Layout > ,
178178 target_block : BlockPtr ,
179179 ) -> Result < CopyState , StoreError > {
180- let tables = TableState :: load ( conn, primary, src. as_ref ( ) , dst. as_ref ( ) ) ?;
180+ let tables = TableState :: load ( conn, primary, src. as_ref ( ) , dst. as_ref ( ) ) . await ?;
181181 let ( finished, mut unfinished) : ( Vec < _ > , Vec < _ > ) =
182182 tables. into_iter ( ) . partition ( |table| table. finished ( ) ) ;
183183 unfinished. sort_by_key ( |table| table. dst . object . to_string ( ) ) ;
@@ -190,7 +190,7 @@ impl CopyState {
190190 } )
191191 }
192192
193- fn create (
193+ async fn create (
194194 conn : & mut PgConnection ,
195195 primary : Primary ,
196196 src : Arc < Layout > ,
@@ -212,15 +212,18 @@ impl CopyState {
212212 let mut unfinished = Vec :: new ( ) ;
213213 for dst_table in dst. tables . values ( ) {
214214 if let Some ( src_table) = src. table_for_entity ( & dst_table. object ) . ok ( ) {
215- unfinished. push ( TableState :: init (
216- conn,
217- primary. cheap_clone ( ) ,
218- dst. site . clone ( ) ,
219- & src,
220- src_table. clone ( ) ,
221- dst_table. clone ( ) ,
222- & target_block,
223- ) ?) ;
215+ unfinished. push (
216+ TableState :: init (
217+ conn,
218+ primary. cheap_clone ( ) ,
219+ dst. site . clone ( ) ,
220+ & src,
221+ src_table. clone ( ) ,
222+ dst_table. clone ( ) ,
223+ & target_block,
224+ )
225+ . await ?,
226+ ) ;
224227 }
225228 }
226229 unfinished. sort_by_key ( |table| table. dst . object . to_string ( ) ) ;
@@ -324,7 +327,7 @@ struct TableState {
324327}
325328
326329impl TableState {
327- fn init (
330+ async fn init (
328331 conn : & mut PgConnection ,
329332 primary : Primary ,
330333 dst_site : Arc < Site > ,
@@ -334,7 +337,8 @@ impl TableState {
334337 target_block : & BlockPtr ,
335338 ) -> Result < Self , StoreError > {
336339 let vid_range = VidRange :: for_copy ( conn, & src, target_block) ?;
337- let batcher = VidBatcher :: load ( conn, & src_layout. site . namespace , src. as_ref ( ) , vid_range) ?;
340+ let batcher =
341+ VidBatcher :: load ( conn, & src_layout. site . namespace , src. as_ref ( ) , vid_range) . await ?;
338342 Ok ( Self {
339343 primary,
340344 src,
@@ -349,7 +353,7 @@ impl TableState {
349353 self . batcher . finished ( )
350354 }
351355
352- fn load (
356+ async fn load (
353357 conn : & mut PgConnection ,
354358 primary : Primary ,
355359 src_layout : & Layout ,
@@ -408,7 +412,8 @@ impl TableState {
408412 & src_layout. site . namespace ,
409413 & src,
410414 VidRange :: new ( current_vid, target_vid) ,
411- ) ?
415+ )
416+ . await ?
412417 . with_batch_size ( size as usize ) ;
413418
414419 let state = TableState {
@@ -1128,7 +1133,7 @@ impl Connection {
11281133 let primary = self . primary . cheap_clone ( ) ;
11291134 let mut state = self
11301135 . transaction ( |conn| {
1131- async { CopyState :: new ( conn, primary, src, dst, target_block) } . scope_boxed ( )
1136+ CopyState :: new ( conn, primary, src, dst, target_block) . scope_boxed ( )
11321137 } ) ?
11331138 . await ?;
11341139
0 commit comments