added more bugfixes for list dir dump
Some checks are pending
EIVE/eive-obsw/pipeline/pr-develop Build started...

This commit is contained in:
Robin Müller 2023-04-16 02:56:46 +02:00
parent 016fab105e
commit f4fedd20c9
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
3 changed files with 19 additions and 11 deletions

View File

@ -1039,10 +1039,9 @@ ReturnValue_t CoreController::actionListDirectoryDumpDirectly(ActionId_t actionI
}
}
std::array<uint8_t, 1024> dirListingBuf{};
// First four bytes reserved for segment index.
std::memcpy(dirListingBuf.data() + sizeof(uint32_t), repoName, repoNameLen);
// Null termination for ground parser.
dirListingBuf[sizeof(uint32_t) + repoNameLen] = '\0';
dirListingBuf[8] = parser.compressionOptionSet();
// First four bytes reserved for segment index. One byte for compression option information
std::strcpy(reinterpret_cast<char *>(dirListingBuf.data() + 2 * sizeof(uint32_t) + 1), repoName);
std::ifstream ifile(LIST_DIR_DUMP_WORK_FILE, std::ios::binary);
if (ifile.bad()) {
return returnvalue::FAILED;
@ -1053,17 +1052,26 @@ ReturnValue_t CoreController::actionListDirectoryDumpDirectly(ActionId_t actionI
size_t dumpedBytes = 0;
size_t nextDumpLen = 0;
size_t dummy = 0;
size_t maxDumpLen = dirListingBuf.size() - repoNameLen - sizeof(uint32_t);
size_t maxDumpLen = dirListingBuf.size() - 2 * sizeof(uint32_t) - 1 - repoNameLen - 1;
size_t listingDataOffset = 2 * sizeof(uint32_t) + 1 + repoNameLen + 1;
uint32_t chunks = totalFileSize / maxDumpLen;
if (totalFileSize % maxDumpLen != 0) {
chunks++;
}
SerializeAdapter::serialize(&chunks, dirListingBuf.data() + sizeof(uint32_t), &dummy,
dirListingBuf.size() - sizeof(uint32_t),
SerializeIF::Endianness::NETWORK);
while (dumpedBytes < totalFileSize) {
ifile.seekg(dumpedBytes, std::ios::beg);
nextDumpLen = maxDumpLen;
if (totalFileSize - dumpedBytes < maxDumpLen) {
nextDumpLen = totalFileSize - dumpedBytes;
}
SerializeAdapter::serialize(&segmentIdx, dirListingBuf.data(), &dummy, dirListingBuf.size(),
SerializeIF::Endianness::NETWORK);
ifile.read(reinterpret_cast<char *>(dirListingBuf.data() + sizeof(uint32_t) + repoNameLen + 1),
nextDumpLen);
result = actionHelper.reportData(commandedBy, actionId, dirListingBuf.data(), nextDumpLen);
ifile.read(reinterpret_cast<char *>(dirListingBuf.data() + listingDataOffset), nextDumpLen);
result = actionHelper.reportData(commandedBy, actionId, dirListingBuf.data(),
listingDataOffset + nextDumpLen);
if (result != returnvalue::OK) {
// Remove work file when we are done
std::filesystem::remove(LIST_DIR_DUMP_WORK_FILE, e);

View File

@ -134,8 +134,8 @@ class ListDirectoryCmdBase {
bool compressionOptionSet() const { return this->compressOption; }
const char* getRepoName(size_t& repoNameLen) const {
return this->repoName;
repoNameLen = this->repoNameLen;
return this->repoName;
}
size_t getBaseSize() {
@ -186,8 +186,8 @@ class ListDirectoryIntoFile : public ListDirectoryCmdBase {
return result;
}
const char* getTargetName(size_t& targetNameLen) const {
return this->targetName;
targetNameLen = this->targetNameLen;
return this->targetName;
}
private:

2
tmtc

@ -1 +1 @@
Subproject commit bb463aa05cf90809edf852d348ab1f7593ece74e
Subproject commit d623e83be8536f8887f1da00a1f0c4be191db1e8