Fix the exception after DB upload fails while keeping the context

This commit is contained in:
Spxg
2025-05-21 23:54:08 +08:00
parent 255a44a935
commit 50e620ba38
2 changed files with 6 additions and 2 deletions

View File

@@ -46,7 +46,7 @@ pub fn Status() -> impl IntoView {
"This shouldn't happen, please create an issue on github."
}
WorkerError::InvaildState => {
"SQLite is in an abnormal state when executing SQLite."
"SQLite is in an abnormal state when executing SQLite, please enable the discard context option and use it once."
}
WorkerError::LoadDb(_) => {
"Please check whether the imported DB is a SQLite3 file"

View File

@@ -167,7 +167,11 @@ pub async fn prepare(options: PrepareOptions) -> Result<()> {
worker.db = Some(SQLiteDb::open(&worker.open_options.uri())?);
}
let stmts = worker.db.as_ref().unwrap().prepare(&options.sql)?;
let stmts = worker
.db
.as_ref()
.ok_or(WorkerError::InvaildState)?
.prepare(&options.sql)?;
worker.state = SQLiteState::Prepared(PreparedState {
stmts,
prepared: None,