Additional Bug fixes
This commit is contained in:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user