Page MenuHomePhabricator

D14001.diff
No OneTemporary

D14001.diff

diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/BackupOperationsUtilities/BackupOperationsExecutor.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/BackupOperationsUtilities/BackupOperationsExecutor.h
--- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/BackupOperationsUtilities/BackupOperationsExecutor.h
+++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/BackupOperationsUtilities/BackupOperationsExecutor.h
@@ -15,5 +15,6 @@
static void restoreFromBackupLog(
const std::vector<std::uint8_t> &backupLog,
size_t futureID);
+ static void setBackupID(std::string backupID, size_t futureID);
};
} // namespace comm
diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/BackupOperationsUtilities/BackupOperationsExecutor.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/BackupOperationsUtilities/BackupOperationsExecutor.cpp
--- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/BackupOperationsUtilities/BackupOperationsExecutor.cpp
+++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/BackupOperationsUtilities/BackupOperationsExecutor.cpp
@@ -61,4 +61,19 @@
};
GlobalDBSingleton::instance.scheduleOrRunCancellable(job);
}
+
+void BackupOperationsExecutor::setBackupID(
+ std::string backupID,
+ size_t futureID) {
+ taskType job = [backupID, futureID]() {
+ try {
+ DatabaseManager::getQueryExecutor().setMetadata("backupID", backupID);
+ ::resolveUnitFuture(futureID);
+ } catch (const std::exception &e) {
+ ::rejectFuture(futureID, rust::String(e.what()));
+ Logger::log("Setting backupID failed. Details: " + std::string(e.what()));
+ }
+ };
+ GlobalDBSingleton::instance.scheduleOrRunCancellable(job);
+}
} // namespace comm
diff --git a/native/native_rust_library/RustBackupExecutor.h b/native/native_rust_library/RustBackupExecutor.h
--- a/native/native_rust_library/RustBackupExecutor.h
+++ b/native/native_rust_library/RustBackupExecutor.h
@@ -17,5 +17,6 @@
rust::Str maxVersion,
size_t futureID);
void restoreFromBackupLog(rust::Vec<std::uint8_t> backupLog, size_t futureID);
+void setBackupID(rust::Str backupID, size_t futureID);
} // namespace comm
diff --git a/native/native_rust_library/RustBackupExecutor.cpp b/native/native_rust_library/RustBackupExecutor.cpp
--- a/native/native_rust_library/RustBackupExecutor.cpp
+++ b/native/native_rust_library/RustBackupExecutor.cpp
@@ -36,6 +36,10 @@
std::string(backupID), futureID);
}
+void setBackupID(rust::Str backupID, size_t futureID) {
+ BackupOperationsExecutor::setBackupID(std::string(backupID), futureID);
+}
+
void restoreFromMainCompaction(
rust::Str mainCompactionPath,
rust::Str mainCompactionEncryptionKey,
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
@@ -8,7 +8,7 @@
create_main_compaction, get_backup_directory_path,
get_backup_user_keys_file_path, get_siwe_backup_message_path,
restore_from_backup_log, restore_from_main_compaction, secure_store_get,
- string_callback, void_callback,
+ set_backup_id, string_callback, void_callback,
};
use crate::utils::future_manager;
use crate::utils::jsi_callbacks::handle_string_result_as_callback;
@@ -126,6 +126,13 @@
return;
}
+ let (future_id, future) = future_manager::new_future::<()>().await;
+ set_backup_id(&backup_id, future_id);
+ if let Err(err) = future.await {
+ handle_backup_creation_error(backup_id.clone(), err.to_string());
+ return;
+ }
+
trigger_backup_file_upload();
// The promise will be resolved when the backup is uploaded
});
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
@@ -527,6 +527,9 @@
#[cxx_name = "restoreFromBackupLog"]
fn restore_from_backup_log(backup_log: Vec<u8>, future_id: usize);
+
+ #[cxx_name = "setBackupID"]
+ fn set_backup_id(backup_id: &str, future_id: usize);
}
// Future handling from C++

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 6:42 AM (16 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2569491
Default Alt Text
D14001.diff (4 KB)

Event Timeline