feat: use nostrdb for unix and rocksdb for windows

This commit is contained in:
reya
2024-06-02 08:16:59 +07:00
parent 1738cbdd97
commit 38d6c51921
4 changed files with 230 additions and 111 deletions

View File

@@ -96,14 +96,20 @@ fn main() {
// Create data folder if not exist
let home_dir = app.path().home_dir().unwrap();
fs::create_dir_all(home_dir.join("Lume/")).unwrap();
let _ = fs::create_dir_all(home_dir.join("Lume/"));
tauri::async_runtime::block_on(async move {
// Create nostr database connection
let sqlite = SQLiteDatabase::open(home_dir.join("Lume/lume.db")).await;
let db_path = home_dir.join(&"Lume/database");
#[cfg(target_family = "unix")]
let database = NdbDatabase::open(db_path.to_str().unwrap());
#[cfg(target_os = "windows")]
let database = RocksDatabase::open(db_path.to_str().unwrap()).await;
// Create nostr connection
let client = match sqlite {
let client = match database {
Ok(db) => ClientBuilder::default().database(db).build(),
Err(_) => ClientBuilder::default().build(),
};