clean, change default file extension for json
This commit is contained in:
@@ -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<Tera> = Lazy::new(|| {
|
||||
|
||||
type YopaStoreWrapper = web::Data<tokio::sync::RwLock<yopa::Storage>>;
|
||||
|
||||
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)
|
||||
|
||||
@@ -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}")]
|
||||
|
||||
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user