Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3513517
D13931.id46009.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D13931.id46009.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
@@ -33,6 +33,39 @@
tokio::spawn(upload_handler::compaction::cleanup_files(backup_id));
}
+ async fn prepare_user_keys_backup(
+ backup_id: String,
+ backup_secret: String,
+ pickle_key: String,
+ pickled_account: String,
+ siwe_backup_msg: String,
+ ) -> Result<(), String> {
+ let result = create_user_keys_compaction(
+ backup_id.clone(),
+ backup_secret,
+ pickle_key,
+ pickled_account,
+ )
+ .await
+ .map_err(|err| err.to_string());
+
+ if let Err(err) = result {
+ handle_backup_creation_error(backup_id.clone(), err.to_string());
+ return Err(err);
+ }
+
+ if !siwe_backup_msg.is_empty() {
+ if let Err(err) =
+ create_siwe_backup_msg_compaction(&backup_id, siwe_backup_msg).await
+ {
+ handle_backup_creation_error(backup_id.clone(), err.to_string());
+ return Err(err.to_string());
+ }
+ }
+
+ Ok(())
+ }
+
pub fn create_backup(
backup_id: String,
backup_secret: String,
@@ -44,29 +77,19 @@
compaction_upload_promises::insert(backup_id.clone(), promise_id);
RUNTIME.spawn(async move {
- let result = create_userkeys_compaction(
+ if (prepare_user_keys_backup(
backup_id.clone(),
backup_secret,
pickle_key,
pickled_account,
+ siwe_backup_msg.clone(),
)
- .await
- .map_err(|err| err.to_string());
-
- if let Err(err) = result {
- handle_backup_creation_error(backup_id.clone(), err.to_string());
+ .await)
+ .is_err()
+ {
return;
}
- if !siwe_backup_msg.is_empty() {
- if let Err(err) =
- create_siwe_backup_msg_compaction(&backup_id, siwe_backup_msg).await
- {
- handle_backup_creation_error(backup_id.clone(), err.to_string());
- return;
- }
- }
-
let (future_id, future) = future_manager::new_future::<()>().await;
create_main_compaction(&backup_id, future_id);
if let Err(err) = future.await {
@@ -75,7 +98,35 @@
}
trigger_backup_file_upload();
+ // The promise will be resolved when the backup is uploaded
+ });
+ }
+ pub fn create_user_keys_backup(
+ backup_id: String,
+ backup_secret: String,
+ pickle_key: String,
+ pickled_account: String,
+ siwe_backup_msg: String,
+ promise_id: u32,
+ ) {
+ compaction_upload_promises::insert(backup_id.clone(), promise_id);
+
+ RUNTIME.spawn(async move {
+ if (prepare_user_keys_backup(
+ backup_id.clone(),
+ backup_secret,
+ pickle_key,
+ pickled_account,
+ siwe_backup_msg.clone(),
+ )
+ .await)
+ .is_err()
+ {
+ return;
+ }
+
+ trigger_backup_file_upload();
// The promise will be resolved when the backup is uploaded
});
}
@@ -270,7 +321,7 @@
}
}
-pub async fn create_userkeys_compaction(
+pub async fn create_user_keys_compaction(
backup_id: String,
backup_secret: String,
pickle_key: String,
diff --git a/native/native_rust_library/src/lib.rs b/native/native_rust_library/src/lib.rs
--- a/native/native_rust_library/src/lib.rs
+++ b/native/native_rust_library/src/lib.rs
@@ -436,6 +436,16 @@
promise_id: u32,
);
+ #[cxx_name = "createUserKeysBackup"]
+ fn create_user_keys_backup(
+ backup_id: String,
+ backup_secret: String,
+ pickle_key: String,
+ pickled_account: String,
+ siwe_backup_msg: String,
+ promise_id: u32,
+ );
+
#[cxx_name = "restoreBackup"]
fn restore_backup(
backup_secret: String,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 12:25 AM (12 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2692946
Default Alt Text
D13931.id46009.diff (3 KB)
Attached To
Mode
D13931: [backup-client][native_rust_library] implement creating User Keys backup
Attached
Detach File
Event Timeline
Log In to Comment