add more context info for dumped dir listing
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
This commit is contained in:
parent
143002de48
commit
0185691dba
@ -1018,26 +1018,37 @@ ReturnValue_t CoreController::actionListDirectoryDumpDirectly(ActionId_t actionI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::array<uint8_t, 1024> dirListingBuf{};
|
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);
|
std::ifstream ifile(LIST_DIR_DUMP_WORK_FILE, std::ios::binary);
|
||||||
if (ifile.bad()) {
|
if (ifile.bad()) {
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
std::error_code e;
|
std::error_code e;
|
||||||
size_t totalFileSize = std::filesystem::file_size(LIST_DIR_DUMP_WORK_FILE, e);
|
size_t totalFileSize = std::filesystem::file_size(LIST_DIR_DUMP_WORK_FILE, e);
|
||||||
|
uint32_t segmentIdx = 0;
|
||||||
size_t dumpedBytes = 0;
|
size_t dumpedBytes = 0;
|
||||||
size_t nextDumpLen = 0;
|
size_t nextDumpLen = 0;
|
||||||
|
size_t dummy = 0;
|
||||||
|
size_t maxDumpLen = dirListingBuf.size() - repoNameLen - sizeof(uint32_t);
|
||||||
while (dumpedBytes < totalFileSize) {
|
while (dumpedBytes < totalFileSize) {
|
||||||
nextDumpLen = 1024;
|
nextDumpLen = maxDumpLen;
|
||||||
if (totalFileSize - dumpedBytes < 1024) {
|
if (totalFileSize - dumpedBytes < maxDumpLen) {
|
||||||
nextDumpLen = totalFileSize - dumpedBytes;
|
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);
|
result = actionHelper.reportData(commandedBy, actionId, dirListingBuf.data(), nextDumpLen);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
// Remove work file when we are done
|
// Remove work file when we are done
|
||||||
std::filesystem::remove(LIST_DIR_DUMP_WORK_FILE, e);
|
std::filesystem::remove(LIST_DIR_DUMP_WORK_FILE, e);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
segmentIdx++;
|
||||||
}
|
}
|
||||||
// Remove work file when we are done
|
// Remove work file when we are done
|
||||||
std::filesystem::remove(LIST_DIR_DUMP_WORK_FILE, e);
|
std::filesystem::remove(LIST_DIR_DUMP_WORK_FILE, e);
|
||||||
|
2
tmtc
2
tmtc
@ -1 +1 @@
|
|||||||
Subproject commit d00e4247f66eb2f010f1fe53ee7f59b7fb992481
|
Subproject commit 37bb164cc461abd51668038e02c5f76db70e7ca6
|
Loading…
x
Reference in New Issue
Block a user