fix(rustdb-storage): return empty collection list for missing databases

This commit is contained in:
2026-05-28 09:18:48 +00:00
parent 03fabaa26b
commit fd2c3ed63d
6 changed files with 1168 additions and 1940 deletions
+1 -1
View File
@@ -473,7 +473,7 @@ impl FileStorageAdapter {
fn list_collection_dirs(&self, db: &str) -> StorageResult<Vec<String>> {
let db_dir = self.db_dir(db);
if !db_dir.exists() {
return Err(StorageError::NotFound(format!("database '{db}'")));
return Ok(Vec::new());
}
let mut colls = Vec::new();
let entries = std::fs::read_dir(&db_dir)?;
+3 -4
View File
@@ -129,10 +129,9 @@ impl StorageAdapter for MemoryStorageAdapter {
// ---- collection ----
async fn list_collections(&self, db: &str) -> StorageResult<Vec<String>> {
let db_ref = self
.data
.get(db)
.ok_or_else(|| StorageError::NotFound(format!("database '{db}'")))?;
let Some(db_ref) = self.data.get(db) else {
return Ok(Vec::new());
};
Ok(db_ref.iter().map(|e| e.key().clone()).collect())
}