diff --git a/services/backup/src/Reactors/server/PullBackupReactor.h b/services/backup/src/Reactors/server/PullBackupReactor.h --- a/services/backup/src/Reactors/server/PullBackupReactor.h +++ b/services/backup/src/Reactors/server/PullBackupReactor.h @@ -37,6 +37,7 @@ std::vector> logs; size_t currentLogIndex = 0; std::shared_ptr currentLog; + size_t currentChunkCounter = 0; void initializeGetReactor(const std::string &holder); diff --git a/services/backup/src/Reactors/server/PullBackupReactor.cpp b/services/backup/src/Reactors/server/PullBackupReactor.cpp --- a/services/backup/src/Reactors/server/PullBackupReactor.cpp +++ b/services/backup/src/Reactors/server/PullBackupReactor.cpp @@ -60,6 +60,7 @@ std::string dataChunk; this->dataChunks->blockingRead(dataChunk); if (!dataChunk.empty()) { + response->set_chunkcounter(this->currentChunkCounter++); response->set_compactionchunk(dataChunk); return nullptr; } @@ -72,6 +73,7 @@ this->getReactor->getStatusHolder()->getStatus().error_message()); } this->state = State::LOGS; + this->currentChunkCounter = 0; } if (this->state == State::LOGS) { // TODO make sure logs are received in correct order regardless their size @@ -108,7 +110,9 @@ // data to the client and reset currentLog so the next invocation of // writeResponse will take another one from the collection response->set_logchunk(this->currentLog->getValue()); + response->set_chunkcounter(this->currentChunkCounter); ++this->currentLogIndex; + this->currentChunkCounter = 0; this->currentLog = nullptr; return nullptr; } @@ -126,10 +130,12 @@ // If there's data inside, we write it to the client and proceed. if (dataChunk.empty()) { ++this->currentLogIndex; + this->currentChunkCounter = 0; this->currentLog = nullptr; return nullptr; } else { response->set_logchunk(dataChunk); + response->set_chunkcounter(this->currentChunkCounter++); } return nullptr; }