feat/vaults
Tomáš Mládek 2020-09-20 19:32:28 +02:00
parent 0e0afae089
commit 967e3a3c7d
4 changed files with 4 additions and 10 deletions

View File

@ -3,9 +3,8 @@ use crate::database::{
insert_entry, insert_file, query_entries, retrieve_object, DbPool, Entry, EntryQuery,
EntryValue, InnerEntry,
};
use crate::hash::{hash, ComputeHash, Hashable, HasherWorker};
use crate::hash::Hashable;
use crate::models;
use actix::prelude::*;
use anyhow::{anyhow, Error, Result};
use chrono::prelude::*;
use diesel::sqlite::Sqlite;
@ -245,9 +244,9 @@ pub fn fetch_or_create_dir<C: Connection<Backend = Sqlite>>(
};
let _ = insert_entry(connection, directory_entry)?;
if parent.is_some() {
if let Some(parent_addr) = parent {
let has_entry = InnerEntry {
target: parent.unwrap(),
target: parent_addr,
key: String::from(DIR_HAS_KEY),
value: EntryValue::Address(new_directory_address.clone()),
};

View File

@ -1,7 +1,7 @@
use actix::prelude::*;
use anyhow::{anyhow, Result};
use filebuffer::FileBuffer;
use std::path::{Path, PathBuf};
use std::path::PathBuf;
use tiny_keccak::{Hasher, KangarooTwelve};
#[derive(Debug, Clone, PartialEq)]

View File

@ -7,7 +7,6 @@ use std::env;
use std::net::SocketAddr;
use std::path::PathBuf;
use actix::prelude::*;
use actix_web::{middleware, App, HttpServer};
use anyhow::Result;
use clap::{App as ClapApp, Arg};
@ -61,7 +60,6 @@ fn main() -> Result<()> {
.expect("failed to open database!");
let db_pool = open_result.pool;
let hash_addr = SyncArbiter::start(4, || hash::HasherWorker);
let bind: SocketAddr = matches
.value_of("BIND")
@ -73,7 +71,6 @@ fn main() -> Result<()> {
let state = routes::State {
directory: vault_path.clone(),
db_pool: db_pool.clone(),
hasher: hash_addr.clone(),
};
// Start HTTP server

View File

@ -2,7 +2,6 @@ use crate::addressing::Address;
use crate::database::{lookup_by_filename, retrieve_by_hash, retrieve_object, DbPool, Entry};
use crate::filesystem::{list_directory, UPath};
use crate::hash::{decode, encode};
use actix::prelude::*;
use actix_files::NamedFile;
use actix_web::error::{ErrorBadRequest, ErrorInternalServerError, ErrorNotFound};
use actix_web::{error, get, post, web, Error, HttpResponse};
@ -16,7 +15,6 @@ use std::path::PathBuf;
pub struct State {
pub directory: PathBuf,
pub db_pool: DbPool,
pub hasher: Addr<crate::hash::HasherWorker>,
}
#[get("/raw/{hash}")]