clean, change default file extension for json

master
Ondřej Hruška 3 anos atrás
commit 66213fceb2
Assinado por: MightyPork
ID da chave GPG: 2C5FD5035250423D
  1. 2
      .gitignore
  2. BIN
      yopa-store.dat
  3. 10
      yopa-web/src/main.rs
  4. 2
      yopa-web/src/routes/models/property.rs
  5. 2
      yopa-web/src/routes/models/relation.rs

2
.gitignore externo

@ -1,3 +1,5 @@
/target
.idea/
yopa/target
yopa-store.dat
yopa-store.json

Arquivo binário não exibido.

@ -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)]

Carregando…
Cancelar
Salvar