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 @@ -55,9 +55,11 @@ } public static String - getBackupFilePath(String backupID, boolean isAttachments) { + getBackupFilePath(String backupID, boolean isAttachments, boolean isVersion) { if (isAttachments) { return getBackupFilePathInternal(backupID, "attachments"); + } else if (isVersion) { + return getBackupFilePathInternal(backupID, "dbVersion"); } return getBackupFilePathInternal(backupID, null); } diff --git a/native/cpp/CommonCpp/DatabaseManagers/DatabaseManager.cpp b/native/cpp/CommonCpp/DatabaseManagers/DatabaseManager.cpp --- a/native/cpp/CommonCpp/DatabaseManagers/DatabaseManager.cpp +++ b/native/cpp/CommonCpp/DatabaseManagers/DatabaseManager.cpp @@ -297,9 +297,9 @@ std::string mainCompactionEncryptionKey, std::string newLogEncryptionKey) { std::string finalBackupPath = - PlatformSpecificTools::getBackupFilePath(backupID, false); + PlatformSpecificTools::getBackupFilePath(backupID, false, false); std::string finalAttachmentsPath = - PlatformSpecificTools::getBackupFilePath(backupID, true); + PlatformSpecificTools::getBackupFilePath(backupID, true, false); std::string tempBackupPath = finalBackupPath + "_tmp"; std::string tempAttachmentsPath = finalAttachmentsPath + "_tmp"; 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 @@ -11,7 +11,7 @@ static std::string getNotificationsCryptoAccountPath(); static std::string getBackupDirectoryPath(); static std::string - getBackupFilePath(std::string backupID, bool isAttachments); + getBackupFilePath(std::string backupID, bool isAttachments, bool isVersion); static std::string getBackupLogFilePath( std::string backupID, std::string logID, 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 @@ -90,11 +90,15 @@ std::string PlatformSpecificTools::getBackupFilePath( std::string backupID, - bool isAttachments) { + bool isAttachments, + bool isVersion) { if (isAttachments) { return getBackupFilePathInternal(backupID, @"attachments"); } + if (isVersion) { + return getBackupFilePathInternal(backupID, @"dbVersion"); + } return getBackupFilePathInternal(backupID, nil); } 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 @@ -5,7 +5,8 @@ namespace comm { rust::String getBackupDirectoryPath(); -rust::String getBackupFilePath(rust::Str backupID, bool isAttachments); +rust::String +getBackupFilePath(rust::Str backupID, bool isAttachments, bool isVersion); rust::String getBackupLogFilePath(rust::Str backupID, rust::Str logID, bool isAttachments); rust::String getBackupUserKeysFilePath(rust::Str backupID); 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 @@ -10,15 +10,18 @@ return rust::String(PlatformSpecificTools::getBackupDirectoryPath()); } -rust::String getBackupFilePath(rust::Str backupID, bool isAttachments) { - return rust::String(PlatformSpecificTools::getBackupFilePath( - std::string(backupID), isAttachments)); +rust::String +getBackupFilePath(rust::Str backupID, bool isAttachments, bool isVersion) { + return rust::String( + PlatformSpecificTools::getBackupFilePath( + std::string(backupID), isAttachments, isVersion)); } rust::String getBackupLogFilePath(rust::Str backupID, rust::Str logID, bool isAttachments) { - return rust::String(PlatformSpecificTools::getBackupLogFilePath( - std::string(backupID), std::string(logID), isAttachments)); + return rust::String( + PlatformSpecificTools::getBackupLogFilePath( + std::string(backupID), std::string(logID), isAttachments)); } rust::String getBackupUserKeysFilePath(rust::Str backupID) { diff --git a/native/native_rust_library/src/backup/upload_handler.rs b/native/native_rust_library/src/backup/upload_handler.rs --- a/native/native_rust_library/src/backup/upload_handler.rs +++ b/native/native_rust_library/src/backup/upload_handler.rs @@ -311,7 +311,7 @@ user_identity: &UserIdentity, backup_id: String, ) -> Result<(), BackupHandlerError> { - let user_data_path = get_backup_file_path(&backup_id, false)?; + let user_data_path = get_backup_file_path(&backup_id, false, false)?; let user_data = match tokio::fs::read(&user_data_path).await { Ok(data) => Some(data), Err(err) if err.kind() == ErrorKind::NotFound => None, @@ -324,7 +324,7 @@ Err(err) => return Err(err.into()), }; - let attachments_path = get_backup_file_path(&backup_id, true)?; + let attachments_path = get_backup_file_path(&backup_id, true, false)?; let attachments = match tokio::fs::read(&attachments_path).await { Ok(data) => data.lines().collect::>()?, Err(err) if err.kind() == ErrorKind::NotFound => Vec::new(), @@ -378,9 +378,9 @@ pub async fn cleanup_files(backup_id: String) { let backup_files_cleanup = async { let paths_to_remove = vec![ - get_backup_file_path(&backup_id, false)?, + get_backup_file_path(&backup_id, false, false)?, get_backup_user_keys_file_path(&backup_id)?, - get_backup_file_path(&backup_id, true)?, + get_backup_file_path(&backup_id, true, false)?, get_siwe_backup_message_path(&backup_id)?, ]; 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 @@ -498,6 +498,7 @@ fn get_backup_file_path( backup_id: &str, is_attachments: bool, + is_version: bool, ) -> Result; #[cxx_name = "getBackupLogFilePath"]