add more context info for dumped dir listing
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2023-04-15 20:51:46 +02:00
parent 143002de48
commit 0185691dba
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
2 changed files with 15 additions and 4 deletions

View File

@ -1018,26 +1018,37 @@ 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';
std::ifstream ifile(LIST_DIR_DUMP_WORK_FILE, std::ios::binary);
if (ifile.bad()) {
return returnvalue::FAILED;
}
std::error_code e;
size_t totalFileSize = std::filesystem::file_size(LIST_DIR_DUMP_WORK_FILE, e);
uint32_t segmentIdx = 0;
size_t dumpedBytes = 0;
size_t nextDumpLen = 0;
size_t dummy = 0;
size_t maxDumpLen = dirListingBuf.size() - repoNameLen - sizeof(uint32_t);
while (dumpedBytes < totalFileSize) {
nextDumpLen = 1024;
if (totalFileSize - dumpedBytes < 1024) {
nextDumpLen = maxDumpLen;
if (totalFileSize - dumpedBytes < maxDumpLen) {
nextDumpLen = totalFileSize - dumpedBytes;
}
ifile.read(reinterpret_cast<char *>(dirListingBuf.data()), nextDumpLen);
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);
if (result != returnvalue::OK) {
// Remove work file when we are done
std::filesystem::remove(LIST_DIR_DUMP_WORK_FILE, e);
return result;
}
segmentIdx++;
}
// Remove work file when we are done
std::filesystem::remove(LIST_DIR_DUMP_WORK_FILE, e);

2
tmtc

@ -1 +1 @@
Subproject commit d00e4247f66eb2f010f1fe53ee7f59b7fb992481
Subproject commit 37bb164cc461abd51668038e02c5f76db70e7ca6