Skip to content

Commit

Permalink
Issue #269: Merge remote-tracking branch 'origin/269-problems-with-oo…
Browse files Browse the repository at this point in the history
…d-daemon-restore-backup-data' into main
  • Loading branch information
lurenpluto committed May 15, 2023
2 parents 89110cc + cb051d3 commit 3cd354a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/component/cyfs-backup-lib/src/backup/restore_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use serde::{Deserialize, Serialize};
pub enum RestoreTaskPhase {
Init,
LoadAndVerify,
RestoreKeyData,
RestoreObject,
RestoreChunk,
RestoreKeyData,
Complete,
}

Expand Down
21 changes: 13 additions & 8 deletions src/component/cyfs-backup/src/backup/uni_restore_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,12 @@ impl UniRestoreTask {

let filter = UniRestoreDataFilter::new();

// Should ignore chunks of key-data
if meta.key_data.len() > 0 {
filter.append_key_data_chunks(&meta.key_data);

let key_data_restore = KeyDataRestoreManager::new(
meta.key_data.clone(),
loader.clone(),
restorer.clone(),
self.status_manager.clone(),
);
key_data_restore.run().await?;
}

// First store objects and chunks
let chunk_fixer = ChunkTrackerFixer::new(&params.isolate)?;

let uni_restore = UniRestoreManager::new(
Expand All @@ -109,6 +103,17 @@ impl UniRestoreTask {
);
uni_restore.run().await?;

// At last restore key-data, which includes {cyfs}/etc/desc
if meta.key_data.len() > 0 {
let key_data_restore = KeyDataRestoreManager::new(
meta.key_data.clone(),
loader.clone(),
restorer.clone(),
self.status_manager.clone(),
);
key_data_restore.run().await?;
}

let result = RestoreResult {
index: loader.index().await,
uni_meta: Some(meta),
Expand Down
3 changes: 2 additions & 1 deletion src/component/cyfs-backup/src/key_data/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ impl KeyDataRestoreManager {
}

pub async fn run(&self) -> BuckyResult<()> {
for item in &self.list {
// The recovery operation is performed in reverse order to ensure that {cyfs}/etc/desc is restored at the end
for item in self.list.iter().rev() {
info!("will restore key data: {:?}", item);

self.restore_data(item).await?;
Expand Down

0 comments on commit 3cd354a

Please sign in to comment.