From 5c1997f64d1dcb91571b70f0e9876cdb89f4c46c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=8C=E8=8D=89=E9=85=B8=E9=85=AF?= <17663689+kotori2@users.noreply.github.com> Date: Sun, 7 Feb 2021 03:48:51 +0800 Subject: [PATCH] [core] Check variant_path when updating config file (#89) --- core/src/main/cpp/main/src/config_manager.cpp | 17 +++++++++++------ core/src/main/cpp/main/src/config_manager.h | 2 -- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/core/src/main/cpp/main/src/config_manager.cpp b/core/src/main/cpp/main/src/config_manager.cpp index 83d1868c..a6d2e68f 100644 --- a/core/src/main/cpp/main/src/config_manager.cpp +++ b/core/src/main/cpp/main/src/config_manager.cpp @@ -214,12 +214,17 @@ namespace lspd { } fs::file_time_type ConfigManager::GetLastWriteTime() const { - auto config_path = GetConfigPath(); - auto list_path = GetConfigPath("modules.list"); - return std::max({path_exists(config_path) ? fs::last_write_time(config_path) - : fs::file_time_type{}, - path_exists(list_path) ? fs::last_write_time(list_path) - : fs::file_time_type{},}); + auto last_write_time = [](std::string_view path) __attribute__((always_inline)) { + return path_exists(path) ? fs::last_write_time(path) : fs::file_time_type{}; + }; + std::string config_path = GetConfigPath(); + std::string list_path = GetConfigPath("modules.list"); + std::string variant_path = GetVariantPath(); + return std::max({ + last_write_time(config_path), + last_write_time(list_path), + last_write_time(variant_path) + }); } bool ConfigManager::InitConfigPath() const { diff --git a/core/src/main/cpp/main/src/config_manager.h b/core/src/main/cpp/main/src/config_manager.h index 6ec603cf..5a681e66 100644 --- a/core/src/main/cpp/main/src/config_manager.h +++ b/core/src/main/cpp/main/src/config_manager.h @@ -130,8 +130,6 @@ namespace lspd { ConfigManager(uid_t uid, bool initialized = false); - static std::unordered_set GetAppList(const std::filesystem::path &dir); - std::string RetrieveInstallerPkgName() const; static std::string GetPackageNameFromBaseApkPath(const std::filesystem::path &path);