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
This commit is contained in:
Tianjie Xu
2018-02-27 15:56:11 -08:00
parent ac4818d6af
commit 3bbb20f557
11 changed files with 139 additions and 27 deletions
@@ -34,12 +34,6 @@ struct FileContents {
std::vector<unsigned char> data;
};
// When there isn't enough room on the target filesystem to hold the patched version of the file,
// we copy the original here and delete it to free up space. If the expected source file doesn't
// exist, or is corrupted, we look to see if the cached file contains the bits we want and use it as
// the source instead. The default location for the cached source is "/cache/saved.file".
extern std::string cache_temp_source;
using SinkFn = std::function<size_t(const unsigned char*, size_t)>;
// applypatch.cpp