mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-24 13:40:31 +01:00
feat: Fix the index opening when index already exists
This commit is contained in:
parent
e08edc2d6b
commit
62c8f1ba04
@ -39,17 +39,26 @@ impl Database {
|
|||||||
let path = path.as_ref();
|
let path = path.as_ref();
|
||||||
let cache = RwLock::new(HashMap::new());
|
let cache = RwLock::new(HashMap::new());
|
||||||
|
|
||||||
let inner = {
|
let options = {
|
||||||
let options = {
|
let mut options = rocksdb::Options::default();
|
||||||
let mut options = rocksdb::Options::default();
|
options.create_if_missing(true);
|
||||||
options.create_if_missing(true);
|
options
|
||||||
options
|
|
||||||
};
|
|
||||||
let cfs = rocksdb::DB::list_cf(&options, path).unwrap_or(Vec::new());
|
|
||||||
Arc::new(rocksdb::DB::open_cf(&options, path, cfs)?)
|
|
||||||
};
|
};
|
||||||
|
let cfs = rocksdb::DB::list_cf(&options, path).unwrap_or(Vec::new());
|
||||||
|
let inner = Arc::new(rocksdb::DB::open_cf(&options, path, &cfs)?);
|
||||||
|
let database = Database { cache, inner };
|
||||||
|
|
||||||
Ok(Database { cache, inner })
|
let mut indexes: Vec<_> = cfs.iter()
|
||||||
|
.filter_map(|c| c.split('-').nth(0).filter(|&c| c != "default"))
|
||||||
|
.collect();
|
||||||
|
indexes.sort_unstable();
|
||||||
|
indexes.dedup();
|
||||||
|
|
||||||
|
for index in indexes {
|
||||||
|
database.open_index(index)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(database)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn indexes(&self) -> Result<Option<HashSet<String>>, Error> {
|
pub fn indexes(&self) -> Result<Option<HashSet<String>>, Error> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user