This commit is contained in:
AB
2020-06-04 00:48:23 +03:00
parent 29eacf8302
commit 049646e40c
4 changed files with 22 additions and 16 deletions

View File

@ -76,10 +76,10 @@ pub fn read() -> Config {
warn!("Insecure server detected. Set `username` and `password` directives to use auth."); warn!("Insecure server detected. Set `username` and `password` directives to use auth.");
} }
Config { Config {
server: server, server,
username: username, username,
password: password, password,
mountpoint: mountpoint, mountpoint,
conf_file: config_file.to_string(), conf_file: config_file.to_string(),
} }
} }

View File

@ -11,9 +11,9 @@ use polyfuse::{
Context, DirEntry, FileAttr, Filesystem, Forget, Operation, Context, DirEntry, FileAttr, Filesystem, Forget, Operation,
}; };
use slab::Slab; use slab::Slab;
use std::error::Error;
use std::mem::swap;
use std::path::{Path, PathBuf}; use std::path::{PathBuf};
use std::{ use std::{
collections::hash_map::{Entry, HashMap}, collections::hash_map::{Entry, HashMap},
ffi::{OsStr, OsString}, ffi::{OsStr, OsString},
@ -27,6 +27,7 @@ use tracing_futures::Instrument;
type Ino = u64; type Ino = u64;
//noinspection RsUnresolvedReference
#[derive(Debug)] #[derive(Debug)]
struct INodeTable { struct INodeTable {
map: HashMap<Ino, Arc<Mutex<INode>>>, map: HashMap<Ino, Arc<Mutex<INode>>>,
@ -46,10 +47,12 @@ impl INodeTable {
VacantEntry { table: self, ino } VacantEntry { table: self, ino }
} }
//noinspection RsUnresolvedReference
fn get(&self, ino: Ino) -> Option<Arc<Mutex<INode>>> { fn get(&self, ino: Ino) -> Option<Arc<Mutex<INode>>> {
self.map.get(&ino).cloned() self.map.get(&ino).cloned()
} }
//noinspection RsUnresolvedReference
fn remove(&mut self, ino: Ino) -> Option<Arc<Mutex<INode>>> { fn remove(&mut self, ino: Ino) -> Option<Arc<Mutex<INode>>> {
self.map.remove(&ino) self.map.remove(&ino)
} }
@ -66,6 +69,7 @@ impl VacantEntry<'_> {
self.ino self.ino
} }
//noinspection RsUnresolvedReference
fn insert(self, inode: INode) { fn insert(self, inode: INode) {
let Self { table, ino } = self; let Self { table, ino } = self;
table.map.insert(ino, Arc::new(Mutex::new(inode))); table.map.insert(ino, Arc::new(Mutex::new(inode)));
@ -124,6 +128,9 @@ struct DirHandle {
entries: Vec<Arc<DirEntry>>, entries: Vec<Arc<DirEntry>>,
} }
//noinspection RsUnresolvedReference
//noinspection RsUnresolvedReference
//noinspection RsUnresolvedReference
#[derive(Debug)] #[derive(Debug)]
pub struct MemFS { pub struct MemFS {
inodes: Mutex<INodeTable>, inodes: Mutex<INodeTable>,
@ -133,6 +140,8 @@ pub struct MemFS {
} }
impl MemFS { impl MemFS {
//noinspection RsUnresolvedReference
//noinspection RsUnresolvedReference
pub fn new(cfg: &config::Config) -> Self { pub fn new(cfg: &config::Config) -> Self {
let mut inodes = INodeTable::new(); let mut inodes = INodeTable::new();
//let self.cfg = cfg; //let self.cfg = cfg;
@ -383,7 +392,7 @@ impl MemFS {
_ => None, _ => None,
} }
} }
Err(e) => None, Err(_e) => None,
} }
} }
@ -597,6 +606,7 @@ impl MemFS {
Some((uri, parent_ino)) Some((uri, parent_ino))
} }
//noinspection RsUnresolvedReference
async fn do_opendir(&self, op: &op::Opendir<'_>) -> io::Result<ReplyOpen> { async fn do_opendir(&self, op: &op::Opendir<'_>) -> io::Result<ReplyOpen> {
error!("do_opendir: {:?}", op); error!("do_opendir: {:?}", op);

View File

@ -1,11 +1,7 @@
extern crate base64; extern crate base64;
use reqwest::{blocking::Client, header::CONTENT_LENGTH};
use serde::Deserialize; use serde::Deserialize;
use std::{ use std::{
collections::{BTreeMap, HashMap, HashSet},
env,
ffi::OsStr,
fmt,
path::PathBuf, path::PathBuf,
process, process,
thread::sleep, thread::sleep,
@ -27,8 +23,8 @@ impl RemoteEntry {
} }
} }
use chrono::format::ParseError;
use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime}; use chrono::{DateTime};
pub async fn list_directory( pub async fn list_directory(
server: &std::string::String, server: &std::string::String,

View File

@ -2,7 +2,7 @@ use std::path::PathBuf;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
use env_logger::Env; use env_logger::Env;
use std::{path::Path, process}; use std::{process};
mod config; mod config;
mod filesystem; mod filesystem;