diff --git a/services/backup/docker-server/contents/server/src/Reactors/server/PullBackupReactor.h b/services/backup/docker-server/contents/server/src/Reactors/server/PullBackupReactor.h --- a/services/backup/docker-server/contents/server/src/Reactors/server/PullBackupReactor.h +++ b/services/backup/docker-server/contents/server/src/Reactors/server/PullBackupReactor.h @@ -29,6 +29,7 @@ std::shared_ptr backupItem; std::shared_ptr getReactor; + std::mutex reactorStateMutex; std::shared_ptr> dataChunks; ServiceBlobClient blobClient; State state = State::COMPACTION; @@ -65,7 +66,24 @@ } void PullBackupReactor::initialize() { - throw std::runtime_error("unimplemented"); + // we make sure that the blob client's state is flushed to the main memory + // as there may be multiple threads from the pool taking over here + const std::lock_guard lock(this->reactorStateMutex); + if (this->request.userid().empty()) { + throw std::runtime_error("no user id provided"); + } + if (this->request.backupid().empty()) { + throw std::runtime_error("no backup id provided"); + } + this->backupItem = database::DatabaseManager::getInstance().findBackupItem( + this->request.userid(), this->request.backupid()); + if (this->backupItem == nullptr) { + throw std::runtime_error( + "no backup found for provided parameters: user id [" + + this->request.userid() + "], backup id [" + this->request.backupid() + + "]"); + } + // TODO get logs } std::unique_ptr