Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3117887
D13840.id45503.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D13840.id45503.diff
View Options
diff --git a/native/backup/use-client-backup.js b/native/backup/use-client-backup.js
--- a/native/backup/use-client-backup.js
+++ b/native/backup/use-client-backup.js
@@ -66,28 +66,6 @@
console.info('Backup uploaded.');
}, [currentUserID, loggedIn, currentUserInfo]);
- const restorePasswordUserBackupProtocol = React.useCallback(async () => {
- if (!loggedIn || !currentUserID) {
- throw new Error('Attempt to restore backup for not logged in user.');
- }
-
- if (!accountHasPassword(currentUserInfo)) {
- throw new Error(
- 'Attempt to restore from password for non-password user.',
- );
- }
-
- console.info('Start restoring backup...');
-
- const backupSecret = await getBackupSecret();
- await commCoreModule.restoreBackup(
- backupSecret,
- persistConfig.version.toString(),
- );
-
- console.info('Backup restored.');
- }, [currentUserID, loggedIn, currentUserInfo]);
-
const retrieveLatestSIWEBackupData = React.useCallback(async () => {
if (!loggedIn || !currentUserID) {
throw new Error('Attempt to restore backup for not logged in user.');
@@ -123,6 +101,27 @@
);
}, [currentUserID, currentUserInfo, loggedIn]);
+ const restorePasswordUserBackupProtocol = React.useCallback(async () => {
+ if (!accountHasPassword(currentUserInfo)) {
+ throw new Error(
+ 'Attempt to restore from password for non-password user.',
+ );
+ }
+
+ const [latestBackupInfo, backupSecret] = await Promise.all([
+ retrieveLatestBackupInfo(),
+ getBackupSecret(),
+ ]);
+
+ console.info('Start restoring backup...');
+ await commCoreModule.restoreBackup(
+ backupSecret,
+ persistConfig.version.toString(),
+ latestBackupInfo.backupID,
+ );
+ console.info('Backup restored.');
+ }, [currentUserInfo, retrieveLatestBackupInfo]);
+
return React.useMemo(
() => ({
uploadBackupProtocol,
diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.h b/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
--- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
+++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
@@ -228,7 +228,8 @@
virtual jsi::Value restoreBackup(
jsi::Runtime &rt,
jsi::String backupSecret,
- jsi::String maxVersion) override;
+ jsi::String maxVersion,
+ jsi::String backupID) override;
virtual jsi::Value restoreSIWEBackup(
jsi::Runtime &rt,
jsi::String backupSecret,
diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
--- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
+++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
@@ -2574,10 +2574,13 @@
jsi::Value CommCoreModule::restoreBackup(
jsi::Runtime &rt,
jsi::String backupSecret,
- jsi::String maxVersion) {
+ jsi::String maxVersion,
+ jsi::String backupID) {
std::string backupSecretStr = backupSecret.utf8(rt);
std::string maxVersionStr = maxVersion.utf8(rt);
- return restoreBackupInternal(rt, backupSecretStr, "", maxVersionStr);
+ std::string backupIDStr = backupID.utf8(rt);
+
+ return restoreBackupInternal(rt, backupSecretStr, backupIDStr, maxVersionStr);
}
jsi::Value CommCoreModule::restoreSIWEBackup(
diff --git a/native/cpp/CommonCpp/_generated/commJSI-generated.cpp b/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
--- a/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
+++ b/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
@@ -188,7 +188,7 @@
return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->createNewSIWEBackup(rt, args[0].asString(rt), args[1].asString(rt));
}
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_restoreBackup(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
- return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->restoreBackup(rt, args[0].asString(rt), args[1].asString(rt));
+ return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->restoreBackup(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt));
}
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_restoreSIWEBackup(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->restoreSIWEBackup(rt, args[0].asString(rt), args[1].asString(rt), args[2].asString(rt));
@@ -306,7 +306,7 @@
methodMap_["stopBackupHandler"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_stopBackupHandler};
methodMap_["createNewBackup"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_createNewBackup};
methodMap_["createNewSIWEBackup"] = MethodMetadata {2, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_createNewSIWEBackup};
- methodMap_["restoreBackup"] = MethodMetadata {2, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_restoreBackup};
+ methodMap_["restoreBackup"] = MethodMetadata {3, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_restoreBackup};
methodMap_["restoreSIWEBackup"] = MethodMetadata {3, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_restoreSIWEBackup};
methodMap_["restoreBackupData"] = MethodMetadata {4, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_restoreBackupData};
methodMap_["retrieveBackupKeys"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_retrieveBackupKeys};
diff --git a/native/cpp/CommonCpp/_generated/commJSI.h b/native/cpp/CommonCpp/_generated/commJSI.h
--- a/native/cpp/CommonCpp/_generated/commJSI.h
+++ b/native/cpp/CommonCpp/_generated/commJSI.h
@@ -76,7 +76,7 @@
virtual void stopBackupHandler(jsi::Runtime &rt) = 0;
virtual jsi::Value createNewBackup(jsi::Runtime &rt, jsi::String backupSecret) = 0;
virtual jsi::Value createNewSIWEBackup(jsi::Runtime &rt, jsi::String backupSecret, jsi::String siweBackupMsg) = 0;
- virtual jsi::Value restoreBackup(jsi::Runtime &rt, jsi::String backupSecret, jsi::String maxVersion) = 0;
+ virtual jsi::Value restoreBackup(jsi::Runtime &rt, jsi::String backupSecret, jsi::String maxVersion, jsi::String backupID) = 0;
virtual jsi::Value restoreSIWEBackup(jsi::Runtime &rt, jsi::String backupSecret, jsi::String backupID, jsi::String maxVersion) = 0;
virtual jsi::Value restoreBackupData(jsi::Runtime &rt, jsi::String backupID, jsi::String backupDataKey, jsi::String backupLogDataKey, jsi::String maxVersion) = 0;
virtual jsi::Value retrieveBackupKeys(jsi::Runtime &rt, jsi::String backupSecret) = 0;
@@ -565,13 +565,13 @@
return bridging::callFromJs<jsi::Value>(
rt, &T::createNewSIWEBackup, jsInvoker_, instance_, std::move(backupSecret), std::move(siweBackupMsg));
}
- jsi::Value restoreBackup(jsi::Runtime &rt, jsi::String backupSecret, jsi::String maxVersion) override {
+ jsi::Value restoreBackup(jsi::Runtime &rt, jsi::String backupSecret, jsi::String maxVersion, jsi::String backupID) override {
static_assert(
- bridging::getParameterCount(&T::restoreBackup) == 3,
- "Expected restoreBackup(...) to have 3 parameters");
+ bridging::getParameterCount(&T::restoreBackup) == 4,
+ "Expected restoreBackup(...) to have 4 parameters");
return bridging::callFromJs<jsi::Value>(
- rt, &T::restoreBackup, jsInvoker_, instance_, std::move(backupSecret), std::move(maxVersion));
+ rt, &T::restoreBackup, jsInvoker_, instance_, std::move(backupSecret), std::move(maxVersion), std::move(backupID));
}
jsi::Value restoreSIWEBackup(jsi::Runtime &rt, jsi::String backupSecret, jsi::String backupID, jsi::String maxVersion) override {
static_assert(
diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js
--- a/native/schema/CommCoreModuleSchema.js
+++ b/native/schema/CommCoreModuleSchema.js
@@ -161,7 +161,11 @@
backupSecret: string,
siweBackupMsg: string,
) => Promise<void>;
- +restoreBackup: (backupSecret: string, maxVersion: string) => Promise<string>;
+ +restoreBackup: (
+ backupSecret: string,
+ maxVersion: string,
+ backupID: string,
+ ) => Promise<string>;
+restoreSIWEBackup: (
backupSecret: string,
backupID: string,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 1, 11:30 PM (22 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2398755
Default Alt Text
D13840.id45503.diff (8 KB)
Attached To
Mode
D13840: [backup-client] make `backupID` mandatory when restoring backup
Attached
Detach File
Event Timeline
Log In to Comment