From 599505977725ba12d5844539eddea01f952967c3 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Wed, 13 Dec 2023 15:45:36 +0100 Subject: [PATCH] better error log + fix broken accept on file creation error --- solanaceae/ngc_ft1_sha1/file_rw_mapped.hpp | 3 ++- solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/solanaceae/ngc_ft1_sha1/file_rw_mapped.hpp b/solanaceae/ngc_ft1_sha1/file_rw_mapped.hpp index 8848ca0..1b024eb 100644 --- a/solanaceae/ngc_ft1_sha1/file_rw_mapped.hpp +++ b/solanaceae/ngc_ft1_sha1/file_rw_mapped.hpp @@ -6,6 +6,7 @@ #include #include +#include #include struct FileRWMapped : public FileI { @@ -25,7 +26,7 @@ struct FileRWMapped : public FileI { _file_map.map(std::string{file_path}, 0, file_size, err); if (err) { - // TODO: errro + std::cerr << "FileRWMapped error: mapping file failed " << err << "\n"; return; } } diff --git a/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp b/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp index fee043d..b59dfb9 100644 --- a/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp +++ b/solanaceae/ngc_ft1_sha1/sha1_ngcft1.cpp @@ -547,11 +547,11 @@ bool SHA1_NGCFT1::onEvent(const Message::Events::MessageUpdated& e) { // first, open file for write(+readback) std::string full_file_path{e.e.get().save_to_path}; // TODO: replace with filesystem or something - // TODO: ensure dir exists if (full_file_path.back() != '/') { full_file_path += "/"; } + // ensure dir exists std::filesystem::create_directories(full_file_path); const auto& info = ce.get(); @@ -559,14 +559,13 @@ bool SHA1_NGCFT1::onEvent(const Message::Events::MessageUpdated& e) { ce.emplace(std::vector{full_file_path}); - std::unique_ptr file_impl; const bool file_exists = std::filesystem::exists(full_file_path); - - file_impl = std::make_unique(full_file_path, info.file_size); + std::unique_ptr file_impl = std::make_unique(full_file_path, info.file_size); if (!file_impl->isGood()) { std::cerr << "SHA1_NGCFT1 error: failed opening file '" << full_file_path << "'!\n"; - //e.e.remove(); // stop + // we failed opening that filepath, so we should offer the user the oportunity to save it differently + e.e.remove(); // stop return false; }