Skip to content

Commit caca1c1

Browse files
committed
store: Refactor CopyState::create
We need to get TableState::init out of the sync closure
1 parent 2562cbc commit caca1c1

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

store/postgres/src/copy.rs

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -209,25 +209,20 @@ impl CopyState {
209209
))
210210
.execute(conn)?;
211211

212-
let mut unfinished: Vec<_> = dst
213-
.tables
214-
.values()
215-
.filter_map(|dst_table| {
216-
src.table_for_entity(&dst_table.object)
217-
.ok()
218-
.map(|src_table| {
219-
TableState::init(
220-
conn,
221-
primary.cheap_clone(),
222-
dst.site.clone(),
223-
&src,
224-
src_table.clone(),
225-
dst_table.clone(),
226-
&target_block,
227-
)
228-
})
229-
})
230-
.collect::<Result<_, _>>()?;
212+
let mut unfinished = Vec::new();
213+
for dst_table in dst.tables.values() {
214+
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+
)?);
224+
}
225+
}
231226
unfinished.sort_by_key(|table| table.dst.object.to_string());
232227

233228
let values = unfinished

0 commit comments

Comments
 (0)