diff --git a/services/backup/docker-server/contents/server/src/Reactors/server/CreateNewBackupReactor.h b/services/backup/docker-server/contents/server/src/Reactors/server/CreateNewBackupReactor.h --- a/services/backup/docker-server/contents/server/src/Reactors/server/CreateNewBackupReactor.h +++ b/services/backup/docker-server/contents/server/src/Reactors/server/CreateNewBackupReactor.h @@ -1,5 +1,6 @@ #pragma once +#include "DatabaseManager.h" #include "ServerBidiReactorBase.h" #include "ServiceBlobClient.h" #include "Tools.h" @@ -30,6 +31,7 @@ std::string userID; std::string keyEntropy; std::string dataHash; + std::string holder; std::string backupID; std::shared_ptr putReactor; ServiceBlobClient blobClient; @@ -84,8 +86,9 @@ // TODO confirm - holder may be a backup id this->backupID = this->generateBackupID(); + this->holder = this->backupID; this->putReactor = std::make_shared( - this->backupID, this->dataHash, &this->waitingForBlobClientCV); + this->holder, this->dataHash, &this->waitingForBlobClientCV); this->blobClient.put(this->putReactor); return nullptr; } @@ -108,6 +111,20 @@ this->putReactor->scheduleSendingDataChunk(emptyString); std::unique_lock lock2(this->waitingForBlobClientCVMutex); this->waitingForBlobClientCV.wait(lock2); + try { + // TODO add recovery data + // TODO handle attachments holders + database::BackupItem backupItem( + this->userID, + this->backupID, + getCurrentTimestamp(), + generateRandomString(), + this->holder, + {}); + database::DatabaseManager::getInstance().putBackupItem(backupItem); + } catch (std::runtime_error &e) { + std::cout << "db operations error: " << e.what() << std::endl; + } } } // namespace reactor