Skip to content

Commit

Permalink
Clear storage before finalization
Browse files Browse the repository at this point in the history
  • Loading branch information
junha1 committed Apr 23, 2023
1 parent 300c6ca commit cf03033
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions simperby/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ impl Client {
let config = this.config.clone();
let auth = this.auth.clone();
drop(this);
storage::clear(&path).await?;
storage::init(&path, config.clone()).await?;
self.inner = Some(Self::open(&path, config, auth).await?.inner.unwrap());
return Ok(report);
}
Expand Down
7 changes: 7 additions & 0 deletions simperby/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,10 @@ pub(crate) async fn open(
let consensus_state = StorageImpl::open(&consensus_state_path(path)).await?;
Ok((governance_dms, consensus_dms, consensus_state, repository))
}

pub(crate) async fn clear(path: &str) -> Result<()> {
let _ = tokio::fs::remove_dir_all(&governance_dms_path(path)).await;
let _ = tokio::fs::remove_dir_all(&consensus_dms_path(path)).await;
let _ = tokio::fs::remove_dir_all(&consensus_state_path(path)).await;
Ok(())
}

0 comments on commit cf03033

Please sign in to comment.