From 641fa97def3e6ef52471e47ad25d0658ef4d943e Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 25 Apr 2018 18:59:40 -0700 Subject: Rename CacheLocation to Paths. We have a general need for overriding more paths (e.g. "/tmp"), mostly for testing purpose. Rename CacheLocation to Paths, and use that to manage TEMPORARY_{INSTALL,LOG}_FILE. Test: mmma -j bootable/recovery Test: recovery_component_test Change-Id: Ia8ce8e5695df37ca434f13ac4d3206de1e8e9396 --- updater/blockimg.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'updater/blockimg.cpp') diff --git a/updater/blockimg.cpp b/updater/blockimg.cpp index e7d213a71..d767d4467 100644 --- a/updater/blockimg.cpp +++ b/updater/blockimg.cpp @@ -15,8 +15,8 @@ */ #include -#include #include +#include #include #include #include @@ -25,13 +25,12 @@ #include #include #include +#include #include #include #include -#include #include #include -#include #include #include @@ -47,14 +46,15 @@ #include #include #include +#include #include #include #include #include "edify/expr.h" #include "otafault/ota_io.h" -#include "otautil/cache_location.h" #include "otautil/error_code.h" +#include "otautil/paths.h" #include "otautil/print_sha1.h" #include "otautil/rangeset.h" #include "updater/install.h" @@ -74,7 +74,7 @@ static bool is_retry = false; static std::unordered_map stash_map; static void DeleteLastCommandFile() { - std::string last_command_file = CacheLocation::location().last_command_file(); + const std::string& last_command_file = Paths::Get().last_command_file(); if (unlink(last_command_file.c_str()) == -1 && errno != ENOENT) { PLOG(ERROR) << "Failed to unlink: " << last_command_file; } @@ -83,7 +83,7 @@ static void DeleteLastCommandFile() { // Parse the last command index of the last update and save the result to |last_command_index|. // Return true if we successfully read the index. static bool ParseLastCommandFile(int* last_command_index) { - std::string last_command_file = CacheLocation::location().last_command_file(); + const std::string& last_command_file = Paths::Get().last_command_file(); android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(last_command_file.c_str(), O_RDONLY))); if (fd == -1) { if (errno != ENOENT) { @@ -119,7 +119,7 @@ static bool ParseLastCommandFile(int* last_command_index) { // Update the last command index in the last_command_file if the current command writes to the // stash either explicitly or implicitly. static bool UpdateLastCommandIndex(int command_index, const std::string& command_string) { - std::string last_command_file = CacheLocation::location().last_command_file(); + const std::string& last_command_file = Paths::Get().last_command_file(); std::string last_command_tmp = last_command_file + ".tmp"; std::string content = std::to_string(command_index) + "\n" + command_string; android::base::unique_fd wfd( @@ -672,15 +672,11 @@ static int VerifyBlocks(const std::string& expected, const std::vector& } static std::string GetStashFileName(const std::string& base, const std::string& id, - const std::string& postfix) { - if (base.empty()) { - return ""; - } - - std::string fn(CacheLocation::location().stash_directory_base()); - fn += "/" + base + "/" + id + postfix; - - return fn; + const std::string& postfix) { + if (base.empty()) { + return ""; + } + return Paths::Get().stash_directory_base() + "/" + base + "/" + id + postfix; } // Does a best effort enumeration of stash files. Ignores possible non-file items in the stash -- cgit v1.2.3