Page MenuHomePhabricator

D11714.id40009.diff
No OneTemporary

D11714.id40009.diff

diff --git a/native/android/app/src/cpp/PlatformSpecificTools.cpp b/native/android/app/src/cpp/PlatformSpecificTools.cpp
--- a/native/android/app/src/cpp/PlatformSpecificTools.cpp
+++ b/native/android/app/src/cpp/PlatformSpecificTools.cpp
@@ -65,6 +65,13 @@
return method(cls, backupID)->toStdString();
}
+ static std::string getSIWEBackupMessagePath(std::string backupID) {
+ static const auto cls = javaClassStatic();
+ static auto method =
+ cls->getStaticMethod<JString(std::string)>("getSIWEBackupMessagePath");
+ return method(cls, backupID)->toStdString();
+ }
+
static void removeBackupDirectory() {
static const auto cls = javaClassStatic();
static auto method = cls->getStaticMethod<void()>("removeBackupDirectory");
@@ -135,6 +142,15 @@
return path;
}
+std::string
+PlatformSpecificTools::getSIWEBackupMessagePath(std::string backupID) {
+ std::string path;
+ NativeAndroidAccessProvider::runTask([&path, backupID]() {
+ path = PlatformSpecificToolsJavaClass::getSIWEBackupMessagePath(backupID);
+ });
+ return path;
+}
+
void PlatformSpecificTools::removeBackupDirectory() {
NativeAndroidAccessProvider::runTask(
[]() { PlatformSpecificToolsJavaClass::removeBackupDirectory(); });
diff --git a/native/android/app/src/main/java/app/comm/android/fbjni/PlatformSpecificTools.java b/native/android/app/src/main/java/app/comm/android/fbjni/PlatformSpecificTools.java
--- a/native/android/app/src/main/java/app/comm/android/fbjni/PlatformSpecificTools.java
+++ b/native/android/app/src/main/java/app/comm/android/fbjni/PlatformSpecificTools.java
@@ -56,35 +56,29 @@
public static String
getBackupFilePath(String backupID, boolean isAttachments) {
- String backupDirPath = PlatformSpecificTools.getBackupDirectoryPath();
-
- String filename;
if (isAttachments) {
- filename = String.join("-", "backup", backupID, "attachments");
- } else {
- filename = String.join("-", "backup", backupID);
+ return getBackupFilePathInternal(backupID, "attachments");
}
- return String.join(File.separator, backupDirPath, filename);
+ return getBackupFilePathInternal(backupID, null);
}
public static String
getBackupLogFilePath(String backupID, String logID, boolean isAttachments) {
- String backupDirPath = PlatformSpecificTools.getBackupDirectoryPath();
-
- String filename;
+ String suffix;
if (isAttachments) {
- filename =
- String.join("-", "backup", backupID, "log", logID, "attachments");
+ suffix = String.join("-", "log", logID, "attachments");
} else {
- filename = String.join("-", "backup", backupID, "log", logID);
+ suffix = String.join("-", "log", logID);
}
- return String.join(File.separator, backupDirPath, filename);
+ return getBackupFilePathInternal(backupID, suffix);
}
public static String getBackupUserKeysFilePath(String backupID) {
- String backupDirPath = PlatformSpecificTools.getBackupDirectoryPath();
- String filename = String.join("-", "backup", backupID, "userkeys");
- return String.join(File.separator, backupDirPath, filename);
+ return getBackupFilePathInternal(backupID, "userkeys");
+ }
+
+ public static String getSIWEBackupMessagePath(String backupID) {
+ return getBackupFilePathInternal(backupID, "siweBackupMsg");
}
public static void removeBackupDirectory() {
@@ -118,4 +112,17 @@
"Failed to remove backup directory. Details: " + e.getMessage());
}
}
+
+ private static String
+ getBackupFilePathInternal(String backupID, String suffix) {
+ String backupDirPath = PlatformSpecificTools.getBackupDirectoryPath();
+
+ String filename;
+ if (suffix != null) {
+ filename = String.join("-", "backup", backupID, suffix);
+ } else {
+ filename = String.join("-", "backup", backupID);
+ }
+ return String.join(File.separator, backupDirPath, filename);
+ }
}
diff --git a/native/cpp/CommonCpp/Tools/PlatformSpecificTools.h b/native/cpp/CommonCpp/Tools/PlatformSpecificTools.h
--- a/native/cpp/CommonCpp/Tools/PlatformSpecificTools.h
+++ b/native/cpp/CommonCpp/Tools/PlatformSpecificTools.h
@@ -17,6 +17,7 @@
std::string logID,
bool isAttachments);
static std::string getBackupUserKeysFilePath(std::string backupID);
+ static std::string getSIWEBackupMessagePath(std::string backupID);
static void removeBackupDirectory();
};
diff --git a/native/ios/Comm/PlatformSpecificTools.mm b/native/ios/Comm/PlatformSpecificTools.mm
--- a/native/ios/Comm/PlatformSpecificTools.mm
+++ b/native/ios/Comm/PlatformSpecificTools.mm
@@ -69,6 +69,21 @@
return backupDir;
}
+std::string getBackupFilePathInternal(std::string backupID, NSString *suffix) {
+ NSURL *backupDir = getBackupDirAsURL();
+ NSString *backupIDObjC = [NSString stringWithCString:backupID.c_str()
+ encoding:NSUTF8StringEncoding];
+ NSString *filename;
+ if (suffix) {
+ filename =
+ [@[ @"backup", backupIDObjC, suffix ] componentsJoinedByString:@"-"];
+ } else {
+ filename = [@[ @"backup", backupIDObjC ] componentsJoinedByString:@"-"];
+ }
+
+ return [[backupDir URLByAppendingPathComponent:filename].path UTF8String];
+}
+
std::string PlatformSpecificTools::getBackupDirectoryPath() {
return [getBackupDirAsURL().path UTF8String];
}
@@ -77,17 +92,10 @@
std::string backupID,
bool isAttachments) {
- NSURL *backupDir = getBackupDirAsURL();
- NSString *backupIDObjC = [NSString stringWithCString:backupID.c_str()
- encoding:NSUTF8StringEncoding];
- NSString *filename;
if (isAttachments) {
- filename = [@[ @"backup", backupIDObjC, @"attachments" ]
- componentsJoinedByString:@"-"];
- } else {
- filename = [@[ @"backup", backupIDObjC ] componentsJoinedByString:@"-"];
+ return getBackupFilePathInternal(backupID, @"attachments");
}
- return [[backupDir URLByAppendingPathComponent:filename].path UTF8String];
+ return getBackupFilePathInternal(backupID, nil);
}
std::string PlatformSpecificTools::getBackupLogFilePath(
@@ -95,31 +103,26 @@
std::string logID,
bool isAttachments) {
- NSURL *backupDir = getBackupDirAsURL();
- NSString *backupIDObjC = [NSString stringWithCString:backupID.c_str()
- encoding:NSUTF8StringEncoding];
NSString *logIDObjC = [NSString stringWithCString:logID.c_str()
encoding:NSUTF8StringEncoding];
- NSString *filename;
+ NSString *suffix;
if (isAttachments) {
- filename = [@[ @"backup", backupIDObjC, @"log", logIDObjC, @"attachments" ]
- componentsJoinedByString:@"-"];
+ suffix =
+ [@[ @"log", logIDObjC, @"attachments" ] componentsJoinedByString:@"-"];
} else {
- filename = [@[ @"backup", backupIDObjC, @"log", logIDObjC ]
- componentsJoinedByString:@"-"];
+ suffix = [@[ @"log", logIDObjC ] componentsJoinedByString:@"-"];
}
- return [[backupDir URLByAppendingPathComponent:filename].path UTF8String];
+ return getBackupFilePathInternal(backupID, suffix);
}
std::string
PlatformSpecificTools::getBackupUserKeysFilePath(std::string backupID) {
+ return getBackupFilePathInternal(backupID, @"userkeys");
+}
- NSURL *backupDir = getBackupDirAsURL();
- NSString *backupIDObjC = [NSString stringWithCString:backupID.c_str()
- encoding:NSUTF8StringEncoding];
- NSString *filename =
- [@[ @"backup", backupIDObjC, @"userkeys" ] componentsJoinedByString:@"-"];
- return [[backupDir URLByAppendingPathComponent:filename].path UTF8String];
+std::string
+PlatformSpecificTools::getSIWEBackupMessagePath(std::string backupID) {
+ return getBackupFilePathInternal(backupID, @"siweBackupMsg");
}
void PlatformSpecificTools::removeBackupDirectory() {
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
@@ -9,6 +9,7 @@
rust::String
getBackupLogFilePath(rust::Str backupID, rust::Str logID, bool isAttachments);
rust::String getBackupUserKeysFilePath(rust::Str backupID);
+rust::String getSIWEBackupMessagePath(rust::Str backupID);
void createMainCompaction(rust::Str backupID, size_t futureID);
void restoreFromMainCompaction(
rust::Str mainCompactionPath,
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
@@ -26,6 +26,11 @@
PlatformSpecificTools::getBackupUserKeysFilePath(std::string(backupID)));
}
+rust::String getSIWEBackupMessagePath(rust::Str backupID) {
+ return rust::String(
+ PlatformSpecificTools::getSIWEBackupMessagePath(std::string(backupID)));
+}
+
void createMainCompaction(rust::Str backupID, size_t futureID) {
BackupOperationsExecutor::createMainCompaction(
std::string(backupID), futureID);
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
@@ -410,6 +410,9 @@
#[cxx_name = "getBackupUserKeysFilePath"]
fn get_backup_user_keys_file_path(backup_id: &str) -> Result<String>;
+ #[cxx_name = "getSIWEBackupMessagePath"]
+ fn get_siwe_backup_message_path(backup_id: &str) -> Result<String>;
+
#[cxx_name = "createMainCompaction"]
fn create_main_compaction(backup_id: &str, future_id: usize);

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 5, 10:48 AM (16 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2615264
Default Alt Text
D11714.id40009.diff (9 KB)

Event Timeline