files are separate objects
parent
762a7914a1
commit
3cf3343326
|
@ -18,7 +18,9 @@ use uuid::Uuid;
|
|||
|
||||
const DIR_KEY: &str = "DIR";
|
||||
const DIR_HAS_KEY: &str = "DIR_HAS";
|
||||
const FILENAME_KEY: &str = "NAME";
|
||||
|
||||
const FILE_IDENTITY_KEY: &str = "FILE_IS";
|
||||
const FILENAME_KEY: &str = "FILE_NAME";
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct UDirectory {
|
||||
|
@ -245,8 +247,10 @@ async fn _reimport_directory<T: AsRef<Path>>(
|
|||
let components = path.components().collect::<Vec<Component>>();
|
||||
let (filename, dir_path) = components.split_last().unwrap();
|
||||
|
||||
let file_address = Address::UUID(Uuid::new_v4());
|
||||
|
||||
let name_entry = InnerEntry {
|
||||
target: Address::Hash(digest.clone()),
|
||||
target: file_address.clone(),
|
||||
key: FILENAME_KEY.to_string(),
|
||||
value: EntryValue::Value(Value::String(
|
||||
filename.as_os_str().to_string_lossy().to_string(),
|
||||
|
@ -256,6 +260,17 @@ async fn _reimport_directory<T: AsRef<Path>>(
|
|||
.send(crate::database::InsertEntry { entry: name_entry })
|
||||
.await??;
|
||||
|
||||
let identity_entry = InnerEntry {
|
||||
target: file_address.clone(),
|
||||
key: FILE_IDENTITY_KEY.to_string(),
|
||||
value: EntryValue::Address(Address::Hash(digest.clone())),
|
||||
};
|
||||
db_executor
|
||||
.send(crate::database::InsertEntry {
|
||||
entry: identity_entry,
|
||||
})
|
||||
.await??;
|
||||
|
||||
let upath = UPath(
|
||||
iter::once(UDirectory {
|
||||
name: "NATIVE".to_string(),
|
||||
|
@ -270,7 +285,7 @@ async fn _reimport_directory<T: AsRef<Path>>(
|
|||
let dir_has_entry = InnerEntry {
|
||||
target: parent_dir.clone(),
|
||||
key: DIR_HAS_KEY.to_string(),
|
||||
value: EntryValue::Address(Address::Hash(digest)),
|
||||
value: EntryValue::Address(file_address),
|
||||
};
|
||||
db_executor
|
||||
.send(crate::database::InsertEntry {
|
||||
|
|
Loading…
Reference in New Issue