Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33289883
D11344.1768725594.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D11344.1768725594.diff
View Options
diff --git a/native/native_rust_library/src/backup.rs b/native/native_rust_library/src/backup.rs
--- a/native/native_rust_library/src/backup.rs
+++ b/native/native_rust_library/src/backup.rs
@@ -134,8 +134,14 @@
async fn download_backup(
backup_secret: String,
) -> Result<CompactionDownloadResult, Box<dyn Error>> {
- let backup_client = BackupClient::new(BACKUP_SOCKET_ADDR)?;
+ let backup_keys = download_backup_keys(backup_secret).await?;
+ download_backup_data(backup_keys).await
+}
+async fn download_backup_keys(
+ backup_secret: String,
+) -> Result<BackupKeysResult, Box<dyn Error>> {
+ let backup_client = BackupClient::new(BACKUP_SOCKET_ADDR)?;
let user_identity = get_user_identity_from_secure_store()?;
let latest_backup_descriptor = BackupDescriptor::Latest {
@@ -158,6 +164,25 @@
let user_keys =
UserKeys::from_encrypted(&mut encrypted_user_keys, &mut backup_key)?;
+ Ok(BackupKeysResult {
+ backup_id,
+ backup_data_key: user_keys.backup_data_key,
+ backup_log_data_key: user_keys.backup_log_data_key,
+ })
+}
+
+async fn download_backup_data(
+ backup_keys: BackupKeysResult,
+) -> Result<CompactionDownloadResult, Box<dyn Error>> {
+ let backup_client = BackupClient::new(BACKUP_SOCKET_ADDR)?;
+ let user_identity = get_user_identity_from_secure_store()?;
+
+ let BackupKeysResult {
+ backup_id,
+ backup_data_key,
+ backup_log_data_key,
+ } = backup_keys;
+
let backup_data_descriptor = BackupDescriptor::BackupID {
backup_id: backup_id.clone(),
user_identity: user_identity.clone(),
@@ -173,10 +198,10 @@
tokio::fs::write(&backup_restoration_path, encrypted_user_data).await?;
Ok(CompactionDownloadResult {
- backup_id,
backup_restoration_path,
- backup_data_key: user_keys.backup_data_key,
- backup_log_data_key: user_keys.backup_log_data_key,
+ backup_id,
+ backup_data_key,
+ backup_log_data_key,
})
}
@@ -215,6 +240,13 @@
})
}
+#[derive(Debug, Serialize)]
+struct BackupKeysResult {
+ backup_id: String,
+ backup_data_key: String,
+ backup_log_data_key: String,
+}
+
struct CompactionDownloadResult {
backup_id: String,
backup_restoration_path: PathBuf,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 18, 8:39 AM (1 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5951097
Default Alt Text
D11344.1768725594.diff (2 KB)
Attached To
Mode
D11344: [native][rust] Split download_backup to separate ct1 and ct2
Attached
Detach File
Event Timeline
Log In to Comment