fix(rustdb-storage): return empty collection list for missing databases
This commit is contained in:
@@ -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)?;
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user