2021-12-23 23:45:46 +01:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
2020-09-06 12:32:17 +02:00
|
|
|
use chrono::NaiveDateTime;
|
2020-08-27 01:29:44 +02:00
|
|
|
use serde::Serialize;
|
2020-08-27 00:11:50 +02:00
|
|
|
|
2020-09-07 21:21:54 +02:00
|
|
|
use super::schema::{data, files};
|
2021-07-26 21:14:12 +02:00
|
|
|
use crate::util::hash::Hash;
|
2020-09-07 21:21:54 +02:00
|
|
|
|
2021-12-04 16:45:06 +01:00
|
|
|
#[derive(Queryable, Serialize, Clone, Debug)]
|
2020-08-27 00:11:50 +02:00
|
|
|
pub struct File {
|
|
|
|
pub id: i32,
|
2021-02-21 19:43:28 +01:00
|
|
|
pub hash: Hash,
|
2020-08-27 00:11:50 +02:00
|
|
|
pub path: String,
|
|
|
|
pub valid: bool,
|
2020-09-22 00:41:59 +02:00
|
|
|
pub added: NaiveDateTime,
|
|
|
|
pub size: i64,
|
|
|
|
pub mtime: Option<NaiveDateTime>,
|
2020-08-27 00:11:50 +02:00
|
|
|
}
|
|
|
|
|
2021-12-23 23:45:46 +01:00
|
|
|
// todo - remove, try_from the actual model, impl queryable...
|
|
|
|
#[derive(Serialize, Clone, Debug)]
|
|
|
|
pub struct OutFile {
|
|
|
|
pub id: i32,
|
|
|
|
pub hash: Hash,
|
|
|
|
pub path: PathBuf,
|
|
|
|
pub valid: bool,
|
|
|
|
pub added: NaiveDateTime,
|
|
|
|
pub size: i64,
|
|
|
|
pub mtime: Option<NaiveDateTime>,
|
|
|
|
}
|
|
|
|
|
2020-08-27 00:11:50 +02:00
|
|
|
#[derive(Insertable, Debug)]
|
|
|
|
#[table_name = "files"]
|
|
|
|
pub struct NewFile {
|
2020-09-12 14:27:45 +02:00
|
|
|
pub hash: Vec<u8>,
|
2020-08-27 00:11:50 +02:00
|
|
|
pub path: String,
|
2020-09-22 00:41:59 +02:00
|
|
|
pub added: NaiveDateTime,
|
2020-08-27 00:11:50 +02:00
|
|
|
pub size: i64,
|
2020-09-22 00:41:59 +02:00
|
|
|
pub mtime: Option<NaiveDateTime>,
|
2020-08-27 00:11:50 +02:00
|
|
|
}
|
2020-09-07 21:21:54 +02:00
|
|
|
|
|
|
|
#[derive(Queryable, Insertable, Serialize, Debug)]
|
|
|
|
#[table_name = "data"]
|
|
|
|
pub struct Entry {
|
|
|
|
pub identity: Vec<u8>,
|
2021-03-14 10:44:13 +01:00
|
|
|
pub entity: Vec<u8>,
|
|
|
|
pub attribute: String,
|
2020-09-07 21:21:54 +02:00
|
|
|
pub value: String,
|
|
|
|
}
|