diff --git a/pkgs/id/src/web/routes.rs b/pkgs/id/src/web/routes.rs index 7a7f65043..7b98d2e82 100644 --- a/pkgs/id/src/web/routes.rs +++ b/pkgs/id/src/web/routes.rs @@ -150,10 +150,12 @@ pub struct FileInfo { fn classify_tag(name: &str) -> (FileKind, Option) { // Check for auto-backup: "auto-{ISO_DATE}" if let Some(iso_str) = name.strip_prefix("auto-") { - // Try to parse the ISO date to extract a unix timestamp - // Format: 2026-03-12T06:42:30.015Z - let ts = parse_iso_timestamp(iso_str); - return (FileKind::Auto, ts); + // Only an auto-backup when the remainder actually parses as an + // ISO date (format: 2026-03-12T06:42:30.015Z). An ordinary file + // that merely starts with "auto-" (auto-notes.txt) is Primary. + if let Some(ts) = parse_iso_timestamp(iso_str) { + return (FileKind::Auto, Some(ts)); + } } // Check for archive: "{name}.archive.{unix_timestamp}" @@ -2440,6 +2442,22 @@ mod tests { assert!(ts.is_some()); } + #[test] + fn test_classify_tag_auto_prefix_non_date_is_primary() { + // Regression (#809): an ordinary file that merely starts with + // "auto-" is not an auto-backup — only "auto-{ISO_DATE}" is. + for name in [ + "auto-notes.txt", + "auto-2026-report.md", + "auto-", + "auto-draft", + ] { + let (kind, ts) = classify_tag(name); + assert_eq!(kind, FileKind::Primary, "{name}"); + assert!(ts.is_none(), "{name}"); + } + } + #[test] fn test_classify_tag_archive() { let (kind, ts) = classify_tag("notes.md.archive.1711000000");