Fix snapshot engine init failure

next
Sayan Nandan 3 years ago
parent c80d929cf9
commit 90ef10a56d
No known key found for this signature in database
GPG Key ID: 8BC07A0A4D41DD52

@ -19,6 +19,11 @@ All changes in this project will be noted in this file.
- Partial entity syntax: `:table` can be used for referring to the current table. For example
you can use `use :default` instead of `use default:default`
### Fixes
- Fixed snapshot option being silently ignored in configuration file
- Fixed snapshot engine init failure
## Version 0.7.3
### Additions

@ -66,9 +66,6 @@ pub async fn run(
match &snapshot {
SnapshotConfig::Enabled(SnapshotPref { atmost, .. }) => {
engine = SnapshotEngine::new(*atmost);
engine
.parse_dir()
.map_err(|e| format!("Failed to init snapshot engine: {}", e))?;
}
SnapshotConfig::Disabled => {
engine = SnapshotEngine::new_disabled();
@ -78,8 +75,13 @@ pub async fn run(
// restore data
services::restore_data(restore_filepath)
.map_err(|e| format!("Failed to restore data from backup with error: {}", e))?;
// init the store
let db = Corestore::init_with_snapcfg(engine.clone())
.map_err(|e| format!("Error while initializing database: {}", e))?;
// refresh the snapshotengine state
engine
.parse_dir()
.map_err(|e| format!("Failed to init snapshot engine: {}", e))?;
let auth_provider = match auth.origin_key {
Some(key) => {
let authref = db.get_store().setup_auth();

@ -112,6 +112,7 @@ impl SnapshotEngine {
}
pub fn parse_dir(&self) -> SnapshotResult<()> {
let dir = fs::read_dir(DIR_SNAPROOT)?;
let mut local_queue = self.local_queue.lock();
for entry in dir {
let entry = entry?;
if entry.file_type()?.is_dir() {
@ -120,7 +121,7 @@ impl SnapshotEngine {
if !SNAP_MATCH.is_match(&name) {
return Err("unknown file in snapshot directory".into());
}
self.local_queue.lock().push(name.to_string());
local_queue.push(name.to_string());
} else {
return Err("unrecognized file in snapshot directory".into());
}

Loading…
Cancel
Save