memoryd: the day and the month of a time with get, never a slice

Implemented-By: OpenCode session (model recorded in docs/implementer-log.md)
This commit is contained in:
2026-09-25 16:41:44 -07:00
parent 1adce5c9df
commit b98f373ead
5 changed files with 6 additions and 10 deletions
+2 -6
View File
@@ -84,11 +84,7 @@ pub(crate) fn append(store: &Store, mut record: Record, now: Timestamp) -> Resul
// `serde_json::to_string(&record)`, then `store.append(&format!("edits/{month}.jsonl"),
// &format!("{line}\n"))?` where month is the first 7 characters of day. Ok(record.id).
let rfc = now.to_rfc3339();
let day = if rfc.len() >= 10 {
&rfc[..10]
} else {
"0000-00-00"
};
let day = rfc.get(..10).unwrap_or("0000-00-00");
let taken = records(store)?
.iter()
.filter(|r| r.id.starts_with(&format!("{day}-")))
@@ -97,7 +93,7 @@ pub(crate) fn append(store: &Store, mut record: Record, now: Timestamp) -> Resul
let edits_dir = store.path("edits");
std::fs::create_dir_all(&edits_dir).map_err(|e| format!("{}: {e}", edits_dir.display()))?;
let line = serde_json::to_string(&record).map_err(|e| e.to_string())?;
let month = &day[..7];
let month = day.get(..7).unwrap_or("0000-00");
store.append(&format!("edits/{month}.jsonl"), &format!("{line}\n"))?;
Ok(record.id)
}