From 2af2d4016010834168620e5c93644037b074f031 Mon Sep 17 00:00:00 2001 From: dongwlin Date: Wed, 22 Nov 2023 01:01:45 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=8E=BB=E9=99=A4cache=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8E=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/cli/Cache/AdbConfigCache.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/source/cli/Cache/AdbConfigCache.cpp b/source/cli/Cache/AdbConfigCache.cpp index edcd8b9..fd6f0e8 100644 --- a/source/cli/Cache/AdbConfigCache.cpp +++ b/source/cli/Cache/AdbConfigCache.cpp @@ -3,8 +3,7 @@ bool AdbConfigCache::has(const std::string& device_name, const std::string& device_SN) { std::string cache_key = generate_cache_key(device_name, device_SN); - std::string filename = cache_key + ".json"; - std::filesystem::path file_path = adb_config_cache_dir / filename; + std::filesystem::path file_path = adb_config_cache_dir / cache_key; if (!std::filesystem::exists(file_path)) { return false; } @@ -58,8 +57,7 @@ std::string AdbConfigCache::generate_cache_key(const std::string& device_name, c bool AdbConfigCache::save(const std::string& cache_key, const std::string& adb_config) { std::filesystem::create_directories(adb_config_cache_dir); - std::string filename = cache_key + ".json"; - std::filesystem::path file_path = adb_config_cache_dir / filename; + std::filesystem::path file_path = adb_config_cache_dir / cache_key; std::ofstream ofs(file_path, std::ios::out); if (!ofs.is_open()) { std::cerr << "Failed to open cache file: " << file_path << std::endl; @@ -80,8 +78,7 @@ bool AdbConfigCache::load(const std::string& cache_key, std::string& adb_config) return true; } - std::string filename = cache_key + ".json"; - std::filesystem::path file_path = adb_config_cache_dir / filename; + std::filesystem::path file_path = adb_config_cache_dir / cache_key; std::ifstream ifs(file_path, std::ios::in); if (!ifs.is_open()) { std::cerr << "Failed to open cache file: " << file_path << std::endl;