seems to work now
This commit is contained in:
parent
97d41a125b
commit
18b67d18a7
@ -40,7 +40,6 @@ ReturnValue_t PersistentTmStore::buildDumpSet(uint32_t fromUnixSeconds, uint32_t
|
||||
if (not fileOrDir.is_regular_file(e)) {
|
||||
continue;
|
||||
}
|
||||
sif::debug << "Path: " << fileOrDir.path() << std::endl;
|
||||
dumpParams.fileSize = std::filesystem::file_size(fileOrDir.path(), e);
|
||||
if (e) {
|
||||
sif::error << "PersistentTmStore: Could not retrieve file size: " << e.message() << std::endl;
|
||||
@ -76,8 +75,8 @@ ReturnValue_t PersistentTmStore::buildDumpSet(uint32_t fromUnixSeconds, uint32_t
|
||||
DumpIndex dumpIndex;
|
||||
dumpIndex.epoch = fileEpoch;
|
||||
dumpIndex.suffixIdx = extractSuffix(file.string());
|
||||
// sif::debug << "Inserting file " << fileOrDir.path() << std::endl;
|
||||
dumpParams.orderedDumpFilestamps.emplace(dumpIndex);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
}
|
||||
return returnvalue::OK;
|
||||
@ -87,10 +86,11 @@ std::optional<uint8_t> PersistentTmStore::extractSuffix(const std::string& pathS
|
||||
std::string numberStr;
|
||||
// Find the position of the dot at the end of the file path
|
||||
size_t dotPos = pathStr.find_last_of('.');
|
||||
if (dotPos != std::string::npos && dotPos < pathStr.length() - 1) {
|
||||
if ((dotPos < pathStr.length()) and not std::isdigit(pathStr[dotPos + 1])) {
|
||||
return std::nullopt;
|
||||
}
|
||||
// Extract the substring after the dot
|
||||
numberStr = pathStr.substr(dotPos + 1);
|
||||
}
|
||||
std::optional<uint8_t> number;
|
||||
try {
|
||||
number = std::stoi(numberStr);
|
||||
@ -202,7 +202,6 @@ ReturnValue_t PersistentTmStore::storePacket(PusTmReader& reader) {
|
||||
createMostRecentFile(suffix);
|
||||
}
|
||||
|
||||
sif::debug << "active file " << activeFile.value() << std::endl;
|
||||
// Rollover conditions were handled, write to file now
|
||||
std::ofstream of(activeFile.value(), std::ios::app | std::ios::binary);
|
||||
of.write(reinterpret_cast<const char*>(reader.getFullData()),
|
||||
@ -298,12 +297,19 @@ ReturnValue_t PersistentTmStore::loadNextDumpFile() {
|
||||
createFileName(tv, dumpIndex.suffixIdx, fullPathLength);
|
||||
dumpParams.currentFile =
|
||||
path(std::string(reinterpret_cast<const char*>(filePathBuf.data()), fullPathLength));
|
||||
std::ifstream ifile(dumpParams.currentFile, std::ios::binary);
|
||||
if (ifile.bad()) {
|
||||
sif::error << "PersistentTmStore: File is bad" << std::endl;
|
||||
dumpParams.fileSize = std::filesystem::file_size(dumpParams.currentFile, e);
|
||||
if (e) {
|
||||
// TODO: Event?
|
||||
sif::error << "PersistentTmStore: Could not load next dump file: " << e.message()
|
||||
<< std::endl;
|
||||
continue;
|
||||
}
|
||||
sif::debug << baseName << " dump: Loading " << dumpParams.currentFile << std::endl;
|
||||
std::ifstream ifile(dumpParams.currentFile, std::ios::binary);
|
||||
if (ifile.bad()) {
|
||||
sif::error << "PersistentTmStore: File is bad. Loading next file" << std::endl;
|
||||
continue;
|
||||
}
|
||||
// sif::debug << baseName << " dump: Loading " << dumpParams.currentFile << std::endl;
|
||||
ifile.read(reinterpret_cast<char*>(fileBuf.data()),
|
||||
static_cast<std::streamsize>(dumpParams.fileSize));
|
||||
// Increment iterator for next cycle.
|
||||
@ -368,7 +374,6 @@ ReturnValue_t PersistentTmStore::createMostRecentFile(std::optional<uint8_t> suf
|
||||
size_t currentIdx;
|
||||
createFileName(currentTv, suffix, currentIdx);
|
||||
path newPath(std::string(reinterpret_cast<const char*>(filePathBuf.data()), currentIdx));
|
||||
sif::debug << "creating new file: " << newPath << std::endl;
|
||||
std::ofstream of(newPath, std::ios::binary);
|
||||
activeFile = newPath;
|
||||
activeFileTv = currentTv;
|
||||
|
Loading…
Reference in New Issue
Block a user