From 53ce292e82a689d9d15b21d25cf352499ac9c0ad Mon Sep 17 00:00:00 2001 From: Green Sky Date: Tue, 2 Apr 2024 18:01:29 +0200 Subject: [PATCH] fix stack overflow (i am stupid) and some file stack error handling --- src/fragment_store/fragment_store.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/fragment_store/fragment_store.cpp b/src/fragment_store/fragment_store.cpp index 8f5d193a..bc35aa20 100644 --- a/src/fragment_store/fragment_store.cpp +++ b/src/fragment_store/fragment_store.cpp @@ -283,11 +283,6 @@ bool FragmentStore::syncToStorage(FragmentID fid, std::function> meta_file_stack; meta_file_stack.push(std::make_unique(std::string_view{meta_tmp_path.generic_u8string()})); - if (!meta_file_stack.top()->isGood()) { - std::cerr << "FS error: opening file for writing '" << meta_tmp_path << "'\n"; - return {}; - } - if (meta_file_stack.empty()) { std::cerr << "FS error: failed to create temporary meta file stack\n"; std::filesystem::remove(meta_tmp_path); // might have created an empty file @@ -306,10 +301,10 @@ bool FragmentStore::syncToStorage(FragmentID fid, std::function(fid).path + ".tmp"; data_tmp_path.replace_filename("." + data_tmp_path.filename().generic_u8string()); auto data_file_stack = buildFileStackWrite(std::string_view{data_tmp_path.generic_u8string()}, data_enc, data_comp); - if (!data_file_stack.empty()) { + if (data_file_stack.empty()) { while (!meta_file_stack.empty()) { meta_file_stack.pop(); } std::filesystem::remove(meta_tmp_path); - std::cerr << "FS error: failed to create temporary data file\n"; + std::cerr << "FS error: failed to create temporary data file stack\n"; return false; } @@ -389,7 +384,7 @@ bool FragmentStore::syncToStorage(FragmentID fid, std::function buffer; + std::vector buffer(chunk_size); uint64_t buffer_actual_size {0}; do { buffer_actual_size = data_cb(buffer.data(), buffer.size());