Additional Bug fixes

This commit is contained in:
unknown
2026-05-22 11:50:59 +02:00
parent 10bfdfb914
commit a0f7efcd34
12 changed files with 372 additions and 135 deletions

View File

@@ -141,11 +141,20 @@ struct IdListFile {
async fn load_id_set(path: &Path) -> Result<HashSet<i64>> {
if !path.exists() {
tokio::fs::write(path, "[]")
.await
.map_err(|e| cgcx_core::CgcxError::Moderation(e.to_string()))?;
return Ok(HashSet::new());
}
let json = tokio::fs::read_to_string(path)
.await
.map_err(|e| cgcx_core::CgcxError::Moderation(e.to_string()))?;
// Accept either a plain array or the IdListFile object format
if let Ok(ids) = serde_json::from_str::<Vec<i64>>(&json) {
return Ok(ids.into_iter().collect());
}
let file: IdListFile = serde_json::from_str(&json)
.map_err(|e| cgcx_core::CgcxError::Moderation(e.to_string()))?;
Ok(file.ids.into_iter().collect())