-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add --no-update / fix surrealdb version panic
- Loading branch information
Showing
6 changed files
with
52 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use std::{future::Future, pin::Pin}; | ||
|
||
use surrealdb::{ | ||
engine::local::{Db, SurrealKV}, | ||
Error, Surreal, | ||
}; | ||
|
||
use super::dirs::get_project_dirs; | ||
|
||
pub fn get_filesystem_db() -> Pin<Box<dyn Future<Output = Result<Surreal<Db>, Error>>>> { | ||
Box::pin(async { | ||
let dirs = get_project_dirs(); | ||
let db_path = dirs.data_dir(); | ||
|
||
std::fs::create_dir_all(db_path).expect("Failed to create database dir."); | ||
|
||
let db = Surreal::new::<SurrealKV>(db_path).await; | ||
|
||
if let Err(e) = &db { | ||
if e.to_string().contains("given version is older") { | ||
// Breaking SurrealDB update. | ||
// Not sure how to properly migrate to a new version, so | ||
// delete all data and start fresh. | ||
std::fs::remove_dir_all(db_path).expect("Failed to remove database dir."); | ||
return get_filesystem_db().await; | ||
} | ||
} | ||
|
||
db | ||
}) | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub mod db; | ||
mod dirs; | ||
pub mod update; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters