From b8940420bb05847b2999101343f70d58ccc93ba7 Mon Sep 17 00:00:00 2001 From: 0xFFFC0000 <0xFFFC0000@proton.me> Date: Sun, 7 Jul 2024 21:13:12 +0000 Subject: [PATCH] epee: fix mlog filename compare bug. When using a relative path for the log filename, since the iteration on files adds "./" to the beginning of the filename monero-wallet-rpc and monero-wallet-cli cannot find already written log files and therefore rotate indefinitely. --- contrib/epee/src/mlog.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp index 4ca1a3632a..46b5355049 100644 --- a/contrib/epee/src/mlog.cpp +++ b/contrib/epee/src/mlog.cpp @@ -176,11 +176,12 @@ void mlog_configure(const std::string &filename_base, bool console, const std::s std::vector found_files; const boost::filesystem::directory_iterator end_itr; const boost::filesystem::path filename_base_path(filename_base); + const std::string filename_base_name = filename_base_path.filename().string(); const boost::filesystem::path parent_path = filename_base_path.has_parent_path() ? filename_base_path.parent_path() : "."; for (boost::filesystem::directory_iterator iter(parent_path); iter != end_itr; ++iter) { - const std::string filename = iter->path().string(); - if (filename.size() >= filename_base.size() && std::memcmp(filename.data(), filename_base.data(), filename_base.size()) == 0) + const std::string filename = iter->path().filename().string(); + if (filename.size() >= filename_base_name.size() && std::memcmp(filename.data(), filename_base_name.data(), filename_base_name.size()) == 0) { found_files.push_back(iter->path()); }