Skip to content

Commit

Permalink
fix(kw-search): delete datasource node then delete table (#8964)
Browse files Browse the repository at this point in the history
Co-authored-by: Henry Fontanier <[email protected]>
  • Loading branch information
fontanierh and Henry Fontanier authored Nov 27, 2024
1 parent 6478c3e commit 551d655
Showing 1 changed file with 36 additions and 23 deletions.
59 changes: 36 additions & 23 deletions core/bin/dust_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2299,30 +2299,43 @@ async fn tables_delete(
&format!("No table found for id `{}`", table_id),
None,
),
Ok(Some(table)) => match try_join(
table.delete(state.store.clone(), state.databases_store.clone()),
state
Ok(Some(table)) => {
// We delete the data source node first, then the table.
match state
.store
.delete_data_source_node(&data_source_id, &table_id),
)
.await
{
Err(e) => error_response(
StatusCode::INTERNAL_SERVER_ERROR,
"internal_server_error",
"Failed to delete table",
Some(e),
),
Ok(_) => (
StatusCode::OK,
Json(APIResponse {
error: None,
response: Some(json!({
"success": true,
})),
}),
),
},
.delete_data_source_node(&data_source_id, &table_id)
.await
{
Err(e) => error_response(
StatusCode::INTERNAL_SERVER_ERROR,
"internal_server_error",
"Failed to delete data source node",
Some(e),
),
Ok(_) => {
match table
.delete(state.store.clone(), state.databases_store.clone())
.await
{
Err(e) => error_response(
StatusCode::INTERNAL_SERVER_ERROR,
"internal_server_error",
"Failed to delete table",
Some(e),
),
Ok(_) => (
StatusCode::OK,
Json(APIResponse {
error: None,
response: Some(json!({
"success": true,
})),
}),
),
}
}
}
}
}
}

Expand Down

0 comments on commit 551d655

Please sign in to comment.