Skip to content

Commit

Permalink
Release temp full sync snapshot before renaming. (#1369)
Browse files Browse the repository at this point in the history
* Release temp full sync snapshot before renaming.

Otherwise, it will report `PermissionDenied` on Windows.

* Fix.
  • Loading branch information
peilun-conflux authored and Peilun Li committed Apr 28, 2020
1 parent 91da238 commit 4f68b1f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions core/src/sync/state/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,14 @@ impl Restorer {

/// Start to restore chunks asynchronously.
pub fn finalize_restoration(
&self, state_manager: Arc<StateManager>, snapshot_info: SnapshotInfo,
) -> StorageResult<()> {
&mut self, state_manager: Arc<StateManager>,
snapshot_info: SnapshotInfo,
) -> StorageResult<()>
{
// Release temp snapshot db so it can be renamed on Windows.
// `self.verifier` is never unwrapped, so it's safe to set it to None,
self.verifier = None;

state_manager
.get_storage_manager()
.get_snapshot_manager()
Expand Down
3 changes: 2 additions & 1 deletion core/src/sync/state/snapshot_chunk_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,11 @@ impl SnapshotChunkSync {
download_start_time.elapsed()
);

let snapshot_info = inner.snapshot_info.clone();
// start to restore and update status
inner.restorer.finalize_restoration(
ctx.manager.graph.data_man.storage_manager.clone(),
inner.snapshot_info.clone(),
snapshot_info,
)?;
inner.status = Status::Completed;
}
Expand Down

0 comments on commit 4f68b1f

Please sign in to comment.