From 66213fceb2e57cf024bab7f74cb2314f9360fd39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sat, 20 Feb 2021 21:54:16 +0100 Subject: [PATCH] clean, change default file extension for json --- .gitignore | 2 ++ yopa-store.dat | Bin 2402 -> 0 bytes yopa-web/src/main.rs | 10 ++++++---- yopa-web/src/routes/models/property.rs | 2 +- yopa-web/src/routes/models/relation.rs | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) delete mode 100644 yopa-store.dat 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 f72b36755a984b707f4c3cd600035a8104b277f5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2402 zcmZQ#fB*p~eXC>U{MAXWpBt_Fa_61?c7+8h?v|gQ0#j2HA$|DGWVfCkz05VtBAaE| zplTfRGIJAi7@<6v>fZkcf`T_WFPPx9Hz-1C%{iDjx+yT5QWHyxIiO|$*{OL7NtFzY zFkR^GL$|FUdhQO_BCqsyI;(HajnS8f=|i`T6>39reolT7Bg_=2AOiz8nkW8$IQQrK zWq0R}U8`rz`)RTfW-PjMU_p^yl$e=U3{$0@WwmZXzZXMK`$k{w>$o&4Vd3yZ5z5)y_$4 zskmIA>%HeqFmZJ4%rNbVC2%F3KUVk1`(Np7*1pQ_D1kHSaYD5^=Hz6iCzj+F!3;RP zMzS<|oA>$7V(||DA|D}`IJ&=KsV*0o)L?4tyKF5rWc}Tzh)ivlzHYM;CXViIm|pjM zgx=ZWPP?~n^Yv~^uirK?$+Qfn7u{Z1c&8PWX2LC2{d&gWmxNc}EYq9idV25P!!)B? z3=gpUa$dBAI_ZjT$k#@z#CWztg*Rdv0ww%>B5s5H9m^#RG5kOzo$xZf;$(1#|DZWOu{N z$Cb-)nU5=cWG%V2-oEU0V%wChRVODnKY*E!D{66>k1O8__43NCtn?0FnuEB_)rhkn4V2 z;eTV@r^}6dysCBt3zh^6>+z6lKCS{kYw33NYCUK1z7?FQRu^4o!OSN${opd+-_Tm& zvA#?Bjv0p-8^3IIgHT~eqU(=7;?tV7e z!E)!tw>&N = 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)]