diff --git a/src/filesystem.rs b/src/filesystem.rs index b5f6011..c29af58 100644 --- a/src/filesystem.rs +++ b/src/filesystem.rs @@ -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::>(); 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)?; }