Skip to content

Commit

Permalink
don't try to send a request if there was no statements to send
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegn committed Oct 23, 2023
1 parent 7197935 commit edbafb5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 6 additions & 2 deletions crates/corro-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl CorrosionApiClient {
pub async fn schema_from_paths<P: AsRef<Path>>(
&self,
schema_paths: &[P],
) -> Result<ExecResponse, Error> {
) -> Result<Option<ExecResponse>, Error> {
let mut statements = vec![];

for schema_path in schema_paths.iter() {
Expand Down Expand Up @@ -261,7 +261,11 @@ impl CorrosionApiClient {
}
}

self.schema(&statements).await
if statements.is_empty() {
return Ok(None);
}

Ok(Some(self.schema(&statements).await?))
}
}

Expand Down
5 changes: 4 additions & 1 deletion crates/corrosion/src/command/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ pub async fn run(config: Config, config_path: &Utf8PathBuf) -> eyre::Result<()>
.schema_from_paths(config.db.schema_paths.as_slice())
.await
{
Ok(res) => {
Ok(Some(res)) => {
info!("Applied schema in {}s", res.time);
}
Ok(None) => {
info!("No schema files to apply, skipping.");
}
Err(e) => {
error!("could not apply schema: {e}");
}
Expand Down

0 comments on commit edbafb5

Please sign in to comment.