update models, fix build, add chrono

feat/vaults
Tomáš Mládek 2020-09-06 12:32:17 +02:00
parent d7bbb5396c
commit add9dd012f
6 changed files with 14 additions and 4 deletions

3
Cargo.lock generated
View File

@ -481,6 +481,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-integer 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -567,6 +568,7 @@ version = "1.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"chrono 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)",
"diesel_derives 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libsqlite3-sys 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
"r2d2 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1720,6 +1722,7 @@ dependencies = [
"actix_derive 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"anyhow 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)",
"bs58 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"chrono 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)",
"diesel 1.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"diesel_migrations 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -14,8 +14,10 @@ env_logger = "0.7.1"
anyhow = "1.0"
diesel = { version = "1.4.4", features=["sqlite", "r2d2"] }
diesel_migrations = "1.4.0"
diesel = { version = "1.4", features=["sqlite", "r2d2", "chrono"] }
diesel_migrations = "1.4"
chrono = { version = "0.4", features = ["serde"] }
actix = "0.9.0"
actix-web = "2.0"

View File

@ -3,7 +3,7 @@ CREATE TABLE files (
hash VARCHAR NOT NULL,
path VARCHAR NOT NULL,
size BIGINT NOT NULL,
ts DATETIME NOT NULL,
created DATETIME NOT NULL,
valid BOOLEAN NOT NULL DEFAULT TRUE
);

View File

@ -9,6 +9,7 @@ use tiny_keccak::{Hasher, KangarooTwelve};
use walkdir::WalkDir;
use actix::prelude::*;
use chrono::prelude::*;
// use rayon::prelude::*;
// pub struct VaultUpdater(
@ -68,6 +69,7 @@ pub async fn update_directory<T: AsRef<Path>>(
.to_string(),
hash: digest.unwrap().unwrap(),
size,
created: NaiveDateTime::from_timestamp(Utc::now().timestamp(), 0),
};
let _insert_result = db_executor

View File

@ -1,4 +1,5 @@
use super::schema::files;
use chrono::NaiveDateTime;
use serde::Serialize;
#[derive(Queryable, Serialize)]
@ -7,6 +8,7 @@ pub struct File {
pub hash: String,
pub path: String,
pub size: i64,
pub created: NaiveDateTime,
pub valid: bool,
}
@ -16,4 +18,5 @@ pub struct NewFile {
pub hash: String,
pub path: String,
pub size: i64,
pub created: NaiveDateTime,
}

View File

@ -13,7 +13,7 @@ table! {
hash -> Text,
path -> Text,
size -> BigInt,
ts -> Timestamp,
created -> Timestamp,
valid -> Bool,
}
}