From 3bbb20f557790c015e44098098375eb6cc376a42 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Tue, 27 Feb 2018 15:56:11 -0800 Subject: Add a singleton CacheLocation to replace the hard coded locations This class allows us to set the following locations dynamically: cache_temp_source, last_command_file, stash_directory_base. In the updater's main function, we reset the values of these variables to their default locations in /cache; while we can set them to temp files in unit tests or host simulation. Test: unit tests pass Change-Id: I528652650caa41373617ab055d41b1f1a4ec0f87 --- applypatch/freecache.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'applypatch/freecache.cpp') diff --git a/applypatch/freecache.cpp b/applypatch/freecache.cpp index ec1d20cec..ea364d8e6 100644 --- a/applypatch/freecache.cpp +++ b/applypatch/freecache.cpp @@ -33,6 +33,7 @@ #include #include "applypatch/applypatch.h" +#include "otautil/cache_location.h" static int EliminateOpenFiles(std::set* files) { std::unique_ptr d(opendir("/proc"), closedir); @@ -92,7 +93,7 @@ static std::set FindExpendableFiles() { // We can't delete cache_temp_source; if it's there we might have restarted during // installation and could be depending on it to be there. - if (path == cache_temp_source) { + if (path == CacheLocation::location().cache_temp_source()) { continue; } -- cgit v1.2.3