2020-09-12 14:27:45 +02:00
|
|
|
use crate::addressing::Address;
|
2020-09-12 22:50:14 +02:00
|
|
|
use crate::database::{
|
2020-09-20 19:28:44 +02:00
|
|
|
insert_entry, insert_file, query_entries, retrieve_object, DbPool, Entry, EntryQuery,
|
|
|
|
EntryValue, InnerEntry,
|
2020-09-12 22:50:14 +02:00
|
|
|
};
|
2020-09-20 19:28:44 +02:00
|
|
|
use crate::hash::{hash, ComputeHash, Hashable, HasherWorker};
|
2020-09-12 14:27:45 +02:00
|
|
|
use crate::models;
|
2020-09-20 19:28:44 +02:00
|
|
|
use actix::prelude::*;
|
2020-09-20 17:17:43 +02:00
|
|
|
use anyhow::{anyhow, Error, Result};
|
2020-09-20 19:28:44 +02:00
|
|
|
use chrono::prelude::*;
|
|
|
|
use diesel::sqlite::Sqlite;
|
|
|
|
use diesel::Connection;
|
2020-09-15 19:26:47 +02:00
|
|
|
use log::{error, info, trace};
|
2020-09-20 19:28:44 +02:00
|
|
|
use rayon::prelude::*;
|
2020-09-12 14:27:45 +02:00
|
|
|
use serde::export::Formatter;
|
|
|
|
use serde_json::Value;
|
2020-09-12 22:50:14 +02:00
|
|
|
use std::path::{Component, Path, PathBuf};
|
|
|
|
use std::{fs, iter};
|
2020-09-12 14:27:45 +02:00
|
|
|
use uuid::Uuid;
|
2020-09-20 19:28:44 +02:00
|
|
|
use walkdir::WalkDir;
|
2020-09-12 14:27:45 +02:00
|
|
|
|
|
|
|
const DIR_KEY: &str = "DIR";
|
|
|
|
const DIR_HAS_KEY: &str = "DIR_HAS";
|
2020-09-12 23:07:50 +02:00
|
|
|
|
|
|
|
const FILE_IDENTITY_KEY: &str = "FILE_IS";
|
|
|
|
const FILENAME_KEY: &str = "FILE_NAME";
|
2020-08-27 00:11:50 +02:00
|
|
|
|
2020-09-12 22:50:14 +02:00
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
2020-09-12 14:27:45 +02:00
|
|
|
pub struct UDirectory {
|
|
|
|
name: String,
|
|
|
|
}
|
2020-08-27 00:11:50 +02:00
|
|
|
|
2020-09-12 22:50:14 +02:00
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
2020-09-12 14:27:45 +02:00
|
|
|
pub struct UPath(Vec<UDirectory>);
|
|
|
|
|
|
|
|
const TOP_SEPARATOR: &str = "//";
|
|
|
|
|
|
|
|
impl std::str::FromStr for UPath {
|
|
|
|
type Err = anyhow::Error;
|
|
|
|
|
2020-09-13 19:20:32 +02:00
|
|
|
fn from_str(string: &str) -> Result<Self, Self::Err> {
|
2020-09-14 01:16:01 +02:00
|
|
|
if string.is_empty() {
|
2020-09-12 14:27:45 +02:00
|
|
|
Ok(UPath(vec![]))
|
|
|
|
} else {
|
2020-09-13 19:20:32 +02:00
|
|
|
let result = match string.find(TOP_SEPARATOR) {
|
2020-09-12 14:27:45 +02:00
|
|
|
Some(head_idx) => {
|
2020-09-13 19:20:32 +02:00
|
|
|
let (head, rest) = string.split_at(head_idx);
|
2020-09-12 14:27:45 +02:00
|
|
|
let mut result: Vec<UDirectory> = Vec::new();
|
|
|
|
result.push(UDirectory {
|
|
|
|
name: String::from(head),
|
|
|
|
});
|
|
|
|
result.append(
|
|
|
|
rest[TOP_SEPARATOR.len()..rest.len()]
|
2020-09-13 20:10:18 +02:00
|
|
|
.trim_end_matches('/')
|
2020-09-14 01:16:01 +02:00
|
|
|
.split('/')
|
2020-09-12 14:27:45 +02:00
|
|
|
.map(|part| UDirectory {
|
|
|
|
name: String::from(part),
|
|
|
|
})
|
|
|
|
.collect::<Vec<UDirectory>>()
|
|
|
|
.as_mut(),
|
|
|
|
);
|
2020-09-13 19:20:32 +02:00
|
|
|
|
|
|
|
result
|
|
|
|
}
|
|
|
|
None => string
|
2020-09-13 20:10:18 +02:00
|
|
|
.trim_end_matches('/')
|
2020-09-14 01:16:01 +02:00
|
|
|
.split('/')
|
2020-09-13 19:20:32 +02:00
|
|
|
.map(|part| UDirectory {
|
|
|
|
name: String::from(part),
|
|
|
|
})
|
|
|
|
.collect(),
|
|
|
|
};
|
|
|
|
|
|
|
|
for directory in &result {
|
2020-09-14 01:16:01 +02:00
|
|
|
if directory.name.is_empty() {
|
2020-09-13 19:20:32 +02:00
|
|
|
return Err(anyhow!("INVALID PATH: Directory name cannot be empty!"));
|
2020-09-12 14:27:45 +02:00
|
|
|
}
|
|
|
|
}
|
2020-09-13 19:20:32 +02:00
|
|
|
|
|
|
|
Ok(UPath(result))
|
2020-09-12 14:27:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::fmt::Display for UDirectory {
|
|
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
|
|
write!(f, "{}", self.name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::fmt::Display for UPath {
|
|
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
|
|
match self.0.len() {
|
|
|
|
0 => write!(f, ""),
|
|
|
|
1 => write!(f, "{}", self.0.first().unwrap().name),
|
|
|
|
_ => {
|
|
|
|
let (head, tail) = self.0.split_first().unwrap();
|
|
|
|
write!(
|
|
|
|
f,
|
|
|
|
"{}//{}",
|
|
|
|
head.name,
|
|
|
|
tail.iter()
|
|
|
|
.map(|udir| udir.name.clone())
|
|
|
|
.collect::<Vec<String>>()
|
|
|
|
.join("/")
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-13 20:10:18 +02:00
|
|
|
trait EntryList {
|
|
|
|
fn extract_addresses(&self) -> Vec<Address>;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl EntryList for Vec<Entry> {
|
|
|
|
fn extract_addresses(&self) -> Vec<Address> {
|
2020-09-14 01:16:01 +02:00
|
|
|
self.iter()
|
2020-09-13 20:10:18 +02:00
|
|
|
.filter_map(|e| {
|
|
|
|
if let EntryValue::Address(address) = &e.value {
|
|
|
|
Some(address.clone())
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.collect()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-20 19:28:44 +02:00
|
|
|
pub fn list_roots<C: Connection<Backend = Sqlite>>(connection: &C) -> Result<Vec<Entry>> {
|
2020-09-15 19:26:47 +02:00
|
|
|
let all_directories: Vec<Entry> = query_entries(
|
|
|
|
connection,
|
|
|
|
EntryQuery {
|
2020-09-13 20:10:18 +02:00
|
|
|
target: None,
|
|
|
|
key: Some(DIR_KEY.to_string()),
|
|
|
|
value: None,
|
2020-09-15 19:26:47 +02:00
|
|
|
},
|
|
|
|
)?;
|
2020-09-13 20:10:18 +02:00
|
|
|
|
2020-09-15 19:26:47 +02:00
|
|
|
let directories_with_parents: Vec<Address> = query_entries(
|
|
|
|
connection,
|
|
|
|
EntryQuery {
|
2020-09-13 20:10:18 +02:00
|
|
|
target: None,
|
|
|
|
key: Some(DIR_HAS_KEY.to_string()),
|
|
|
|
value: None,
|
2020-09-15 19:26:47 +02:00
|
|
|
},
|
|
|
|
)?
|
|
|
|
.extract_addresses();
|
2020-09-13 20:10:18 +02:00
|
|
|
|
|
|
|
Ok(all_directories
|
|
|
|
.into_iter()
|
|
|
|
.filter(|entry| !directories_with_parents.contains(&entry.target))
|
|
|
|
.collect())
|
|
|
|
}
|
|
|
|
|
2020-09-15 19:26:47 +02:00
|
|
|
pub async fn list_directory<C: Connection<Backend = Sqlite>>(
|
|
|
|
connection: &C,
|
|
|
|
path: &UPath,
|
|
|
|
) -> Result<Vec<Entry>> {
|
2020-09-13 20:10:18 +02:00
|
|
|
let entry_addresses = match path.0.len() {
|
2020-09-20 19:28:44 +02:00
|
|
|
0 => list_roots(connection)?
|
2020-09-13 20:10:18 +02:00
|
|
|
.into_iter()
|
|
|
|
.map(|e| e.target)
|
|
|
|
.collect(),
|
|
|
|
_ => {
|
2020-09-20 19:28:44 +02:00
|
|
|
let resolved_path: Vec<Address> = resolve_path(connection, path, false)?;
|
2020-09-13 20:10:18 +02:00
|
|
|
let last = resolved_path.last().unwrap();
|
|
|
|
|
2020-09-15 19:26:47 +02:00
|
|
|
query_entries(
|
|
|
|
connection,
|
|
|
|
EntryQuery {
|
2020-09-13 20:10:18 +02:00
|
|
|
target: Some(last.clone()),
|
|
|
|
key: Some(DIR_HAS_KEY.to_string()),
|
|
|
|
value: None,
|
2020-09-15 19:26:47 +02:00
|
|
|
},
|
|
|
|
)?
|
|
|
|
.extract_addresses()
|
2020-09-13 20:10:18 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
let mut result: Vec<Entry> = vec![];
|
|
|
|
for address in entry_addresses {
|
|
|
|
result.extend(
|
2020-09-15 19:26:47 +02:00
|
|
|
retrieve_object(connection, address)?
|
2020-09-13 20:10:18 +02:00
|
|
|
.into_iter()
|
|
|
|
.filter(|e| [DIR_KEY, FILENAME_KEY, FILE_IDENTITY_KEY].contains(&e.key.as_str()))
|
|
|
|
.collect::<Vec<Entry>>(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
Ok(result)
|
|
|
|
}
|
|
|
|
|
2020-09-20 19:28:44 +02:00
|
|
|
pub fn fetch_or_create_dir<C: Connection<Backend = Sqlite>>(
|
2020-09-15 19:26:47 +02:00
|
|
|
connection: &C,
|
2020-09-12 14:27:45 +02:00
|
|
|
parent: Option<Address>,
|
|
|
|
directory: UDirectory,
|
2020-09-13 20:10:18 +02:00
|
|
|
create: bool,
|
2020-09-12 14:27:45 +02:00
|
|
|
) -> Result<Address> {
|
2020-09-12 22:50:14 +02:00
|
|
|
match parent.clone() {
|
|
|
|
Some(address) => trace!("FETCHING/CREATING {}/{:#}", address, directory),
|
|
|
|
None => trace!("FETCHING/CREATING /{:#}", directory),
|
|
|
|
}
|
|
|
|
|
2020-09-12 14:27:45 +02:00
|
|
|
let dir_value = EntryValue::Value(Value::String(directory.name));
|
2020-09-15 19:26:47 +02:00
|
|
|
let directories: Vec<Address> = query_entries(
|
|
|
|
connection,
|
|
|
|
EntryQuery {
|
2020-09-12 14:27:45 +02:00
|
|
|
target: None,
|
|
|
|
key: Some(String::from(DIR_KEY)),
|
|
|
|
value: Some(dir_value.clone()),
|
2020-09-15 19:26:47 +02:00
|
|
|
},
|
|
|
|
)?
|
|
|
|
.into_iter()
|
|
|
|
.map(|e: Entry| e.target)
|
|
|
|
.collect();
|
2020-09-12 14:27:45 +02:00
|
|
|
|
|
|
|
let valid_directories: Vec<Address> = match parent.clone() {
|
|
|
|
Some(address) => {
|
2020-09-15 19:26:47 +02:00
|
|
|
let parent_has: Vec<Address> = query_entries(
|
|
|
|
connection,
|
|
|
|
EntryQuery {
|
2020-09-12 14:27:45 +02:00
|
|
|
target: Some(address),
|
|
|
|
key: Some(String::from(DIR_HAS_KEY)),
|
|
|
|
value: None,
|
2020-09-15 19:26:47 +02:00
|
|
|
},
|
|
|
|
)?
|
|
|
|
.extract_addresses();
|
2020-09-12 14:27:45 +02:00
|
|
|
|
2020-09-14 01:16:01 +02:00
|
|
|
directories
|
2020-09-12 14:27:45 +02:00
|
|
|
.into_iter()
|
|
|
|
.filter(|a| parent_has.contains(a))
|
2020-09-14 01:16:01 +02:00
|
|
|
.collect()
|
2020-09-12 14:27:45 +02:00
|
|
|
}
|
|
|
|
None => directories,
|
|
|
|
};
|
|
|
|
|
|
|
|
match valid_directories.len() {
|
|
|
|
0 => {
|
2020-09-13 20:10:18 +02:00
|
|
|
if create {
|
|
|
|
let new_directory_address = Address::UUID(Uuid::new_v4());
|
|
|
|
let directory_entry = InnerEntry {
|
|
|
|
target: new_directory_address.clone(),
|
|
|
|
key: String::from(DIR_KEY),
|
|
|
|
value: dir_value,
|
2020-09-12 14:27:45 +02:00
|
|
|
};
|
2020-09-15 19:26:47 +02:00
|
|
|
let _ = insert_entry(connection, directory_entry)?;
|
2020-09-13 20:10:18 +02:00
|
|
|
|
|
|
|
if parent.is_some() {
|
|
|
|
let has_entry = InnerEntry {
|
|
|
|
target: parent.unwrap(),
|
|
|
|
key: String::from(DIR_HAS_KEY),
|
|
|
|
value: EntryValue::Address(new_directory_address.clone()),
|
|
|
|
};
|
2020-09-15 19:26:47 +02:00
|
|
|
let _ = insert_entry(connection, has_entry)?;
|
2020-09-13 20:10:18 +02:00
|
|
|
}
|
2020-09-12 14:27:45 +02:00
|
|
|
|
2020-09-13 20:10:18 +02:00
|
|
|
Ok(new_directory_address)
|
|
|
|
} else {
|
|
|
|
Err(anyhow!("Directory does not exist."))
|
|
|
|
}
|
2020-09-12 14:27:45 +02:00
|
|
|
}
|
|
|
|
1 => Ok(valid_directories[0].clone()),
|
|
|
|
_ => Err(anyhow!(
|
|
|
|
"Invalid database state - more than one directory matches the query!"
|
|
|
|
)),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-20 19:28:44 +02:00
|
|
|
pub fn resolve_path<C: Connection<Backend = Sqlite>>(
|
2020-09-15 19:26:47 +02:00
|
|
|
connection: &C,
|
2020-09-12 22:50:14 +02:00
|
|
|
path: &UPath,
|
2020-09-13 20:10:18 +02:00
|
|
|
create: bool,
|
2020-09-12 22:50:14 +02:00
|
|
|
) -> Result<Vec<Address>> {
|
|
|
|
let mut result: Vec<Address> = vec![];
|
|
|
|
let mut path_stack = path.0.to_vec();
|
|
|
|
|
|
|
|
path_stack.reverse();
|
2020-09-14 01:16:01 +02:00
|
|
|
while !path_stack.is_empty() {
|
2020-09-12 22:50:14 +02:00
|
|
|
let dir_address = fetch_or_create_dir(
|
2020-09-15 19:26:47 +02:00
|
|
|
connection,
|
2020-09-12 22:50:14 +02:00
|
|
|
result.last().cloned(),
|
|
|
|
path_stack.pop().unwrap(),
|
2020-09-13 20:10:18 +02:00
|
|
|
create,
|
2020-09-20 19:28:44 +02:00
|
|
|
)?;
|
2020-09-12 22:50:14 +02:00
|
|
|
result.push(dir_address);
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(result)
|
2020-09-12 14:27:45 +02:00
|
|
|
}
|
2020-09-20 19:28:44 +02:00
|
|
|
pub async fn reimport_directory(pool: DbPool, directory: PathBuf) {
|
|
|
|
let result = actix_web::web::block(move || _reimport_directory(&pool, directory)).await;
|
2020-09-20 16:29:16 +02:00
|
|
|
if result.is_err() {
|
2020-09-20 19:28:44 +02:00
|
|
|
let err = result.err().unwrap();
|
|
|
|
error!("Update did not succeed! {}", err);
|
2020-09-20 16:29:16 +02:00
|
|
|
}
|
|
|
|
}
|
2020-09-20 19:28:44 +02:00
|
|
|
fn _reimport_directory<T: AsRef<Path>>(pool: &DbPool, directory: T) -> Result<()> {
|
|
|
|
let path_entries: Vec<PathBuf> = WalkDir::new(&directory)
|
2020-08-27 00:11:50 +02:00
|
|
|
.into_iter()
|
|
|
|
.filter_map(|e| e.ok())
|
|
|
|
.filter(|e| e.path().is_file())
|
2020-09-20 19:28:44 +02:00
|
|
|
.filter_map(|e| fs::canonicalize(e.into_path()).ok()) // ???
|
2020-09-13 20:43:45 +02:00
|
|
|
.collect();
|
|
|
|
|
2020-09-20 16:29:16 +02:00
|
|
|
let absolute_path = fs::canonicalize(&directory)?;
|
2020-09-20 19:28:44 +02:00
|
|
|
path_entries
|
|
|
|
.into_par_iter()
|
|
|
|
.map(|path| {
|
|
|
|
Ok(_process_directory_entry(
|
|
|
|
&pool.get()?,
|
|
|
|
path,
|
|
|
|
&absolute_path,
|
|
|
|
)?)
|
|
|
|
})
|
|
|
|
.collect::<Result<()>>()?;
|
2020-08-27 00:11:50 +02:00
|
|
|
info!("Finished updating {}.", directory.as_ref().display());
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2020-09-20 19:28:44 +02:00
|
|
|
fn _process_directory_entry<C: Connection<Backend = Sqlite>, P: AsRef<Path>>(
|
2020-09-20 16:29:16 +02:00
|
|
|
connection: &C,
|
|
|
|
path: PathBuf,
|
|
|
|
directory_path: &P,
|
|
|
|
) -> Result<()> {
|
|
|
|
info!("Processing: {:?}", path);
|
|
|
|
|
|
|
|
let metadata = fs::metadata(&path)?;
|
|
|
|
let size = metadata.len() as i64;
|
|
|
|
if size < 0 {
|
|
|
|
panic!("File {} too large?!", path.display());
|
2020-08-30 22:11:32 +02:00
|
|
|
}
|
2020-09-20 16:29:16 +02:00
|
|
|
|
2020-09-20 19:28:44 +02:00
|
|
|
let digest = path.hash()?;
|
2020-09-20 16:29:16 +02:00
|
|
|
|
|
|
|
// let existing_file: Option<String> = db_executor
|
|
|
|
// .send(RetrieveByHash {
|
|
|
|
// hash: digest.clone(),
|
|
|
|
// })
|
|
|
|
// .await??;
|
|
|
|
|
|
|
|
let new_file = models::NewFile {
|
|
|
|
path: path
|
|
|
|
.strip_prefix(&directory_path)?
|
|
|
|
.to_str()
|
|
|
|
.expect("path not valid unicode?!")
|
|
|
|
.to_string(),
|
|
|
|
hash: (digest.clone()).0,
|
|
|
|
created: NaiveDateTime::from_timestamp(Utc::now().timestamp(), 0),
|
|
|
|
size,
|
|
|
|
};
|
|
|
|
|
|
|
|
let _ = insert_file(connection, new_file)?;
|
|
|
|
|
|
|
|
let components = path
|
|
|
|
.strip_prefix(&directory_path)?
|
|
|
|
.components()
|
|
|
|
.collect::<Vec<Component>>();
|
|
|
|
let (filename, dir_path) = components.split_last().unwrap();
|
|
|
|
|
|
|
|
let upath = UPath(
|
|
|
|
iter::once(UDirectory {
|
|
|
|
name: "NATIVE".to_string(),
|
|
|
|
})
|
|
|
|
.chain(dir_path.iter().map(|component| UDirectory {
|
|
|
|
name: component.as_os_str().to_string_lossy().to_string(),
|
|
|
|
}))
|
|
|
|
.collect(),
|
|
|
|
);
|
2020-09-20 19:28:44 +02:00
|
|
|
let resolved_path = resolve_path(connection, &upath, true)?;
|
2020-09-20 16:29:16 +02:00
|
|
|
let parent_dir = resolved_path.last().unwrap();
|
|
|
|
|
2020-09-20 17:17:43 +02:00
|
|
|
connection.transaction::<_, Error, _>(|| {
|
|
|
|
let file_address = Address::UUID(Uuid::new_v4());
|
|
|
|
|
|
|
|
let name_entry = InnerEntry {
|
|
|
|
target: file_address.clone(),
|
|
|
|
key: FILENAME_KEY.to_string(),
|
|
|
|
value: EntryValue::Value(Value::String(
|
|
|
|
filename.as_os_str().to_string_lossy().to_string(),
|
|
|
|
)),
|
|
|
|
};
|
|
|
|
let _ = insert_entry(connection, name_entry)?;
|
|
|
|
|
|
|
|
let identity_entry = InnerEntry {
|
|
|
|
target: file_address.clone(),
|
|
|
|
key: FILE_IDENTITY_KEY.to_string(),
|
|
|
|
value: EntryValue::Address(Address::Hash(digest.clone())),
|
|
|
|
};
|
|
|
|
|
|
|
|
let _ = insert_entry(connection, identity_entry)?;
|
|
|
|
|
|
|
|
let dir_has_entry = InnerEntry {
|
|
|
|
target: parent_dir.clone(),
|
|
|
|
key: DIR_HAS_KEY.to_string(),
|
|
|
|
value: EntryValue::Address(file_address),
|
|
|
|
};
|
|
|
|
let _ = insert_entry(connection, dir_has_entry)?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
})
|
2020-08-30 22:11:32 +02:00
|
|
|
}
|
2020-09-12 14:27:45 +02:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use crate::filesystem::{UDirectory, UPath};
|
|
|
|
use anyhow::Result;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_path_codec() {
|
|
|
|
let path = UPath(vec![
|
|
|
|
UDirectory {
|
|
|
|
name: "top".to_string(),
|
|
|
|
},
|
|
|
|
UDirectory {
|
|
|
|
name: "foo".to_string(),
|
|
|
|
},
|
|
|
|
UDirectory {
|
|
|
|
name: "bar".to_string(),
|
|
|
|
},
|
|
|
|
UDirectory {
|
|
|
|
name: "baz".to_string(),
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
|
|
|
|
let str_path = path.to_string();
|
|
|
|
assert!(str_path.len() > 0);
|
|
|
|
|
|
|
|
let decoded_path: Result<UPath> = str_path.parse();
|
|
|
|
assert!(decoded_path.is_ok());
|
|
|
|
|
|
|
|
assert_eq!(path, decoded_path.unwrap());
|
|
|
|
}
|
2020-09-13 19:20:32 +02:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_validation() {
|
|
|
|
let invalid_path: Result<UPath> = "a//b/c//d/e/f///g".parse();
|
|
|
|
assert!(invalid_path.is_err())
|
|
|
|
}
|
2020-09-12 14:27:45 +02:00
|
|
|
}
|