Skip to content

Commit

Permalink
fix: temporarily fixing the inability for hot reloading, may result i…
Browse files Browse the repository at this point in the history
…n regression
  • Loading branch information
wxxedu committed Oct 21, 2023
1 parent 82dd502 commit de076db
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion native/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub mod test;

use rusqlite::Connection;
use std::cell::RefCell;
use std::collections::HashMap;

use self::structs::{CArray, CAtom, CEdge, CEventData, CId, CNode, COption, CPair, CResult, CTriple, CUnit};
use crate::{
Expand Down Expand Up @@ -59,8 +60,14 @@ pub extern "C" fn qinhuai_add_acyclic_edge(label: u64) {
#[no_mangle]
pub unsafe extern "C" fn qinhuai_open(len: u64, ptr: *mut u8) -> CResult<CUnit> {
convert_result(|| {
if STORE.with(|cell| cell.borrow().is_some()) {
// FIXME: This is a hack to avoid double-initialisation in flutter's hot reload, but this will
// cause new databases unable to be opened.
return Ok(CUnit(0));
}
let path = CArray(len, ptr).as_ref();
let conn = Connection::open(std::str::from_utf8(path).map_err(|_| StoreError::InvalidUtf8)?)?;
let path = std::str::from_utf8(path).map_err(|_| StoreError::InvalidUtf8)?;
let conn = Connection::open(path)?;
conn.execute_batch(
"
PRAGMA auto_vacuum = INCREMENTAL;
Expand Down

0 comments on commit de076db

Please sign in to comment.