From 95e67bf29162bd7cda3f77d267d468def71db149 Mon Sep 17 00:00:00 2001 From: Horror Proton <107091537+horror-proton@users.noreply.github.com> Date: Tue, 21 Nov 2023 22:22:25 +0800 Subject: [PATCH] perf: do not rotate logs that are symbolic links --- src/MaaCore/Utils/Logger.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/MaaCore/Utils/Logger.hpp b/src/MaaCore/Utils/Logger.hpp index 5b8bb0b8f8..b154f0bdd4 100644 --- a/src/MaaCore/Utils/Logger.hpp +++ b/src/MaaCore/Utils/Logger.hpp @@ -588,13 +588,16 @@ namespace asst { constexpr uintmax_t MaxLogSize = 4ULL * 1024 * 1024; try { - if (std::filesystem::exists(m_log_path)) { + if (std::filesystem::exists(m_log_path) && std::filesystem::is_regular_file(m_log_path)) { const uintmax_t log_size = std::filesystem::file_size(m_log_path); if (log_size >= MaxLogSize) { std::filesystem::rename(m_log_path, m_log_bak_path); } } } + catch (std::filesystem::filesystem_error& e) { + std::cerr << e.what() << std::endl; + } catch (...) { } }