fix: don't stop if failed

This commit is contained in:
Namekuji 2023-09-17 23:44:50 -04:00
parent 7f144d2165
commit ebdc9821b0
No known key found for this signature in database
GPG key ID: 1D62332C07FBA532

View file

@ -53,7 +53,7 @@ impl Initializer {
} }
pub(crate) async fn setup(&self, mt: bool) -> Result<(), Error> { pub(crate) async fn setup(&self, mt: bool) -> Result<(), Error> {
println!("Several tables in PostgreSQL are going to moved to ScyllaDB."); println!("Several tables in PostgreSQL are going to be moved to ScyllaDB.");
let pool = Database::connect(&self.postgres_url).await?; let pool = Database::connect(&self.postgres_url).await?;
let db_backend = pool.get_database_backend(); let db_backend = pool.get_database_backend();
@ -76,7 +76,7 @@ impl Initializer {
return Ok(()); return Ok(());
} }
println!("Copyping data from PostgreSQL to ScyllaDB."); println!("Copying data from PostgreSQL to ScyllaDB.");
self.copy(pool.clone(), mt).await?; self.copy(pool.clone(), mt).await?;
println!("Dropping constraints from PostgreSQL."); println!("Dropping constraints from PostgreSQL.");
@ -202,7 +202,9 @@ impl Initializer {
note_pb.clone(), note_pb.clone(),
); );
let f = async move { let f = async move {
s.copy_note(note, d, n, h).await.expect("Note copy failed"); if let Err(e) = s.copy_note(note, d, n, h).await {
p.println(format!("Note copy error: {e}"));
}
p.inc(1); p.inc(1);
}; };
if multi_thread { if multi_thread {
@ -220,9 +222,9 @@ impl Initializer {
while let Some(reaction) = reactions.try_next().await? { while let Some(reaction) = reactions.try_next().await? {
let (s, r, p) = (self.clone(), reaction_prepared.clone(), reaction_pb.clone()); let (s, r, p) = (self.clone(), reaction_prepared.clone(), reaction_pb.clone());
let f = async move { let f = async move {
s.copy_reaction(reaction, r) if let Err(e) = s.copy_reaction(reaction, r).await {
.await p.println(format!("Reaction copy error: {e}"));
.expect("Reaction copy failed"); }
p.inc(1); p.inc(1);
}; };
if multi_thread { if multi_thread {
@ -246,9 +248,9 @@ impl Initializer {
vote_pb.clone(), vote_pb.clone(),
); );
let f = async move { let f = async move {
s.copy_vote(vote, d, sp, ip) if let Err(e) = s.copy_vote(vote, d, sp, ip).await {
.await p.println(format!("Vote copy error: {e}"));
.expect("Vote copy failed"); }
p.inc(1); p.inc(1);
}; };
if multi_thread { if multi_thread {
@ -271,9 +273,9 @@ impl Initializer {
notification_pb.clone(), notification_pb.clone(),
); );
let f = async move { let f = async move {
s.copy_notification(n, d, ps) if let Err(e) = s.copy_notification(n, d, ps).await {
.await p.println(format!("Notification copy error: {e}"));
.expect("Notification copy failed"); }
p.inc(1); p.inc(1);
}; };
if multi_thread { if multi_thread {
@ -563,12 +565,12 @@ fn map_drive_file(file: drive_file::Model) -> DriveFileType {
.properties .properties
.get("width") .get("width")
.filter(|v| v.is_number()) .filter(|v| v.is_number())
.map(|v| v.as_i64().unwrap() as i32), .map(|v| v.as_i64().unwrap_or_default() as i32),
height: file height: file
.properties .properties
.get("height") .get("height")
.filter(|v| v.is_number()) .filter(|v| v.is_number())
.map(|v| v.as_i64().unwrap() as i32), .map(|v| v.as_i64().unwrap_or_default() as i32),
} }
} }