diff --git a/.gitignore b/.gitignore index 4cb2679..a5e90b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /target .idea/ yopa/target +yopa-store.dat +yopa-store.json diff --git a/yopa-store.dat b/yopa-store.dat deleted file mode 100644 index f72b367..0000000 Binary files a/yopa-store.dat and /dev/null differ diff --git a/yopa-web/src/main.rs b/yopa-web/src/main.rs index 2696da4..9def602 100644 --- a/yopa-web/src/main.rs +++ b/yopa-web/src/main.rs @@ -19,7 +19,7 @@ use once_cell::sync::Lazy; use rand::Rng; use tera::Tera; -use yopa::{Storage}; +use yopa::Storage; use crate::tera_ext::TeraExt; @@ -102,7 +102,7 @@ pub(crate) static TERA: Lazy = Lazy::new(|| { type YopaStoreWrapper = web::Data>; -const DEF_ADDRESS : &str = "127.0.0.1:8080"; +const DEF_ADDRESS: &str = "127.0.0.1:8080"; #[actix_web::main] async fn main() -> std::io::Result<()> { @@ -145,7 +145,9 @@ async fn main() -> std::io::Result<()> { // Ensure the lazy ref is initialized early (to catch template bugs ASAP) let _ = TERA.deref(); - let file = matches.value_of("file").unwrap_or("yopa-store.dat"); + let json = matches.is_present("json"); + + let file = matches.value_of("file").unwrap_or(if json { "yopa-store.json" } else { "yopa-store.dat" }); let file_path = if file.starts_with('/') { std::env::current_dir()?.join(file) @@ -155,7 +157,7 @@ async fn main() -> std::io::Result<()> { debug!("Using database file: {}", file_path.display()); - let mut store = if matches.is_present("json") { + let mut store = if json { Storage::new_json(file_path) } else { Storage::new_bincode(file_path) diff --git a/yopa-web/src/routes/models/property.rs b/yopa-web/src/routes/models/property.rs index a2c58bb..9cf9850 100644 --- a/yopa-web/src/routes/models/property.rs +++ b/yopa-web/src/routes/models/property.rs @@ -8,7 +8,7 @@ use yopa::{DataType, TypedValue, ID}; use crate::routes::models::relation::ObjectOrRelationModelDisplay; use crate::session_ext::SessionExt; use crate::tera_ext::TeraExt; -use crate::utils::{redirect, ParseOrBadReq, StorageErrorIntoResponseError}; +use crate::utils::{redirect, StorageErrorIntoResponseError}; use crate::TERA; #[get("/model/property/create/{object_id}")] diff --git a/yopa-web/src/routes/models/relation.rs b/yopa-web/src/routes/models/relation.rs index 101100c..f89c966 100644 --- a/yopa-web/src/routes/models/relation.rs +++ b/yopa-web/src/routes/models/relation.rs @@ -7,7 +7,7 @@ use yopa::ID; use crate::session_ext::SessionExt; use crate::tera_ext::TeraExt; -use crate::utils::{redirect, ParseOrBadReq, StorageErrorIntoResponseError}; +use crate::utils::{redirect, StorageErrorIntoResponseError}; use crate::TERA; #[derive(Serialize, Debug)]