Skip to content

Commit

Permalink
Skip dropped databases in dump --all (#1215)
Browse files Browse the repository at this point in the history
The CLI obtains the list of databases before dumping all of them and if
a given database was dropped before its turn to get dumped the CLI will
crash.  Skip dropped databases instead.
  • Loading branch information
elprans authored Feb 21, 2024
1 parent e4a3ccd commit b95f4c9
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/commands/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use sha1::Digest;

use tokio_stream::StreamExt;

use edgedb_errors::{UnknownDatabaseError};

use crate::commands::Options;
use crate::commands::list_databases::get_databases;
use crate::commands::parser::{Dump as DumpOptions, DumpFormat};
Expand Down Expand Up @@ -157,11 +159,21 @@ pub async fn dump_all(cli: &mut Connection, options: &Options, dir: &Path,

let mut conn_params = options.conn_params.clone();
for database in &databases {
let mut db_conn = conn_params
.database(database)?
.connect().await?;
let filename = dir.join(&(urlencoding::encode(database) + ".dump")[..]);
dump_db(&mut db_conn, options, &filename, include_secrets).await?;
match conn_params.database(database)?.connect().await {
Ok(mut db_conn) => {
let filename = dir.join(&(urlencoding::encode(database) + ".dump")[..]);
dump_db(&mut db_conn, options, &filename, include_secrets).await?;
},
Err(err) => {
if let Some(e) = err.downcast_ref::<edgedb_errors::Error>() {
if e.is::<UnknownDatabaseError>() {
eprintln!("Database {database} no longer exists, skipping...");
continue;
}
}
return Err(err);
},
}
}

Ok(())
Expand Down

0 comments on commit b95f4c9

Please sign in to comment.