"ADDED" entry for files

feat/vaults
Tomáš Mládek 2022-02-03 09:54:51 +01:00
parent bb081057cf
commit 3cd3df27c0
No known key found for this signature in database
GPG Key ID: ED21612889E75EC5
1 changed files with 13 additions and 1 deletions

View File

@ -2,7 +2,7 @@ use std::borrow::Borrow;
use std::convert::TryFrom;
use std::path::{Component, Path, PathBuf};
use std::sync::{Arc, Mutex, RwLock};
use std::time::{Instant, UNIX_EPOCH};
use std::time::{Instant, SystemTime, UNIX_EPOCH};
use std::{fs, iter};
use crate::addressing::Address;
@ -410,6 +410,17 @@ fn insert_file_with_metadata(
value: EntryValue::String(mime_type),
});
let added_entry = Entry {
entity: Address::Hash(hash.clone()),
attribute: "ADDED".to_string(),
value: EntryValue::Number(
SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs() as f64,
),
};
// Add the appropriate entries w/r/t virtual filesystem location
let components = normalized_path.components().collect::<Vec<Component>>();
let (filename, dir_path) = components.split_last().unwrap();
@ -433,6 +444,7 @@ fn insert_file_with_metadata(
connection.insert_entry_immutable(type_entry)?;
connection.insert_entry_immutable(size_entry)?;
connection.insert_entry_immutable(added_entry)?;
if let Some(mime_entry) = mime_entry {
connection.insert_entry(mime_entry)?;
}