diff --git a/src/database/stores/fs/mod.rs b/src/database/stores/fs/mod.rs
index da8c35d..37a43e8 100644
--- a/src/database/stores/fs/mod.rs
+++ b/src/database/stores/fs/mod.rs
@@ -339,6 +339,7 @@ impl FsStore {
&db.borrow().connection()?,
&normalized_path,
file_hash.unwrap(),
+ None,
size,
mtime,
mime_type,
@@ -350,7 +351,13 @@ impl FsStore {
})
}
- fn add_file(&self, connection: &UpEndConnection, path: &Path, hash: Hash) -> Result
{
+ fn add_file(
+ &self,
+ connection: &UpEndConnection,
+ path: &Path,
+ hash: Hash,
+ name_hint: Option,
+ ) -> Result {
let normalized_path = self.normalize_path(path)?;
let metadata = fs::metadata(path)?;
let size = metadata.len() as i64;
@@ -370,6 +377,7 @@ impl FsStore {
connection,
&normalized_path,
hash,
+ name_hint,
size,
mtime,
mime_type,
@@ -383,6 +391,7 @@ impl FsStore {
connection: &UpEndConnection,
normalized_path: &Path,
hash: Hash,
+ name: Option,
size: i64,
mtime: Option,
mime_type: Option,
@@ -479,7 +488,9 @@ impl FsStore {
let label_entry = Entry {
entity: blob_address.clone(),
attribute: LABEL_ATTR.to_string(),
- value: filename.as_os_str().to_string_lossy().to_string().into(),
+ value: name
+ .unwrap_or_else(|| filename.as_os_str().to_string_lossy().to_string())
+ .into(),
provenance: "SYSTEM INIT".to_string(),
timestamp: chrono::Utc::now().naive_utc(),
};
@@ -643,7 +654,7 @@ impl UpStore for FsStore {
.map_err(|e| StoreError::Unknown(e.to_string()))?,
);
- let final_name = if let Some(name_hint) = name_hint {
+ let final_name = if let Some(name_hint) = &name_hint {
format!("{addr_str}_{name_hint}")
} else {
addr_str
@@ -653,7 +664,7 @@ impl UpStore for FsStore {
fs::copy(file_path, &final_path).map_err(|e| StoreError::Unknown(e.to_string()))?;
- self.add_file(&connection, &final_path, hash.clone())
+ self.add_file(&connection, &final_path, hash.clone(), name_hint)
.map_err(|e| StoreError::Unknown(e.to_string()))?;
}