diff --git a/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h b/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h --- a/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h +++ b/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h @@ -218,6 +218,7 @@ #else virtual void createMainCompaction(std::string backupID) const = 0; virtual void captureBackupLogs() const = 0; + virtual void triggerBackupFileUpload() const = 0; virtual void setUserDataKeys( const std::string &backupDataKey, const std::string &backupLogDataKey) const = 0; diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h --- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h +++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h @@ -238,6 +238,7 @@ static void initialize(std::string &databasePath); void createMainCompaction(std::string backupID) const override; void captureBackupLogs() const override; + void triggerBackupFileUpload() const override; void setUserDataKeys( const std::string &backupDataKey, const std::string &backupLogDataKey) const override; diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp --- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp +++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp @@ -19,9 +19,11 @@ #ifndef EMSCRIPTEN #include "../CryptoTools/CryptoModule.h" +#include "../Tools/ServicesUtils.h" #include "CommSecureStore.h" #include "PlatformSpecificTools.h" #include "StaffUtils.h" +#include "lib.rs.h" #endif const int CONTENT_ACCOUNT_ID = 1; @@ -1428,7 +1430,7 @@ SQLiteQueryExecutor::initializeTablesForLogMonitoring(); std::string currentBackupID = this->getMetadata("backupID"); - if (!StaffUtils::isStaffRelease() || !currentBackupID.size()) { + if (!ServicesUtils::fullBackupSupport || !currentBackupID.size()) { return; } SQLiteQueryExecutor::connectionManager.setLogsMonitoring(true); @@ -3225,7 +3227,7 @@ this->setMetadata("backupID", backupID); this->clearMetadata("logID"); - if (StaffUtils::isStaffRelease()) { + if (ServicesUtils::fullBackupSupport) { SQLiteQueryExecutor::connectionManager.setLogsMonitoring(true); } } @@ -3246,6 +3248,9 @@ } void SQLiteQueryExecutor::captureBackupLogs() const { + if (!ServicesUtils::fullBackupSupport) { + return; + } std::string backupID = this->getMetadata("backupID"); if (!backupID.size()) { return; @@ -3264,6 +3269,13 @@ this->setMetadata("logID", std::to_string(std::stoi(logID) + 1)); } +void SQLiteQueryExecutor::triggerBackupFileUpload() const { + if (!ServicesUtils::fullBackupSupport) { + return; + } + ::triggerBackupFileUpload(); +} + void SQLiteQueryExecutor::setUserDataKeys( const std::string &backupDataKey, const std::string &backupLogDataKey) const { 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 @@ -537,6 +537,7 @@ DatabaseManager::getQueryExecutor().addOutboundP2PMessages( messages); } + DatabaseManager::getQueryExecutor().captureBackupLogs(); DatabaseManager::getQueryExecutor().commitTransaction(); } catch (std::system_error &e) { error = e.what(); @@ -544,6 +545,10 @@ } } + if (!error.size()) { + DatabaseManager::getQueryExecutor().triggerBackupFileUpload(); + } + this->jsInvoker_->invokeAsync([=]() { if (error.size()) { promise->reject(error); diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/BaseDataStore.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/BaseDataStore.h --- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/BaseDataStore.h +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/BaseDataStore.h @@ -51,6 +51,7 @@ for (const auto &operation : storeOps) { operation->execute(); } + DatabaseManager::getQueryExecutor().captureBackupLogs(); DatabaseManager::getQueryExecutor().commitTransaction(); } catch (const std::exception &e) { error = e.what(); @@ -60,6 +61,8 @@ if (error.size()) { throw std::runtime_error(error); } + + DatabaseManager::getQueryExecutor().triggerBackupFileUpload(); }); } };