optimization and test stub

This commit is contained in:
2024-09-05 00:34:36 +02:00
parent 08b9bf99a5
commit 512abdd98a
2 changed files with 6 additions and 4 deletions

View File

@@ -1632,4 +1632,7 @@ mod tests {
assert!(tb.handler.pdu_sender.queue_empty());
tb.expected_full_data = faulty_file_data.to_vec();
}
#[test]
fn test_file_copy_to_directory() {}
}

View File

@@ -137,6 +137,9 @@ pub trait VirtualFilestore {
fn exists(&self, path: &str) -> Result<bool, FilestoreError>;
/// Extract the file name part of a full path.
///
/// This method should behave similarly to the [std::path::Path::file_name] method.
fn file_name<'a>(&self, full_path: &'a str) -> Result<Option<&'a str>, FilestoreError>;
fn file_size(&self, path: &str) -> Result<u64, FilestoreError>;
@@ -213,11 +216,7 @@ pub mod std_mod {
}
fn file_name<'a>(&self, full_path: &'a str) -> Result<Option<&'a str>, FilestoreError> {
if self.is_dir(full_path)? {
return Err(FilestoreError::IsNotFile);
}
let path = Path::new(full_path);
path.file_name()
.map(|s| s.to_str())
.ok_or(FilestoreError::Utf8Error)