fixed fmt

This commit is contained in:
objz committed 2026-08-24 19:17:37 +02:00
1 parent e99e307790
commit e1cce7b5b3
5 files changed
+22 -18

No files matched your search

+1 -4
View File
@@ -243,10 +243,7 @@ fn mirror_dir(src: &Path, dst: &Path) -> Result<(), ConfigSyncError> {
.into());
};
std::fs::create_dir_all(parent)?;
let name = dst
.file_name()
.and_then(|s| s.to_str())
.unwrap_or("mirror");
let name = dst.file_name().and_then(|s| s.to_str()).unwrap_or("mirror");
let staging = parent.join(format!(".{name}.mirror-tmp"));
if staging.exists() {
remove_path(&staging)?;
+11 -7
View File
@@ -12,15 +12,19 @@ fn create_log_file_name_has_millisecond_precision() {
// stem is 22 chars: %Y-%m-%d_%H-%M-%S%3f
let stem = name.strip_suffix(".log").unwrap();
assert_eq!(stem.len(), 22, "name={name}");
assert!(stem[stem.len() - 3..].chars().all(|c| c.is_ascii_digit()), "name={name}");
assert!(
stem[stem.len() - 3..].chars().all(|c| c.is_ascii_digit()),
"name={name}"
);
// pin the pattern: %3f must be zero-padded so names stay sortable
let dt = chrono::NaiveDateTime::parse_from_str(
"2025-01-02T15:04:05.005",
"%Y-%m-%dT%H:%M:%S%.3f",
)
.unwrap();
assert_eq!(dt.format("%Y-%m-%d_%H-%M-%S%3f").to_string(), "2025-01-02_15-04-05005");
let dt =
chrono::NaiveDateTime::parse_from_str("2025-01-02T15:04:05.005", "%Y-%m-%dT%H:%M:%S%.3f")
.unwrap();
assert_eq!(
dt.format("%Y-%m-%d_%H-%M-%S%3f").to_string(),
"2025-01-02_15-04-05005"
);
}
#[test]