summaryrefslogtreecommitdiffstats
path: root/applypatch/applypatch.cpp
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2018-02-28 00:56:11 +0100
committerTianjie Xu <xunchang@google.com>2018-02-28 20:19:11 +0100
commit3bbb20f557790c015e44098098375eb6cc376a42 (patch)
tree9db0b6bd746646486aa990daecf8e3302c49b4c0 /applypatch/applypatch.cpp
parentMerge "Fix the behavior of undefined commands in BlockImageVerify" (diff)
downloadandroid_bootable_recovery-3bbb20f557790c015e44098098375eb6cc376a42.tar
android_bootable_recovery-3bbb20f557790c015e44098098375eb6cc376a42.tar.gz
android_bootable_recovery-3bbb20f557790c015e44098098375eb6cc376a42.tar.bz2
android_bootable_recovery-3bbb20f557790c015e44098098375eb6cc376a42.tar.lz
android_bootable_recovery-3bbb20f557790c015e44098098375eb6cc376a42.tar.xz
android_bootable_recovery-3bbb20f557790c015e44098098375eb6cc376a42.tar.zst
android_bootable_recovery-3bbb20f557790c015e44098098375eb6cc376a42.zip
Diffstat (limited to 'applypatch/applypatch.cpp')
-rw-r--r--applypatch/applypatch.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/applypatch/applypatch.cpp b/applypatch/applypatch.cpp
index 73701abc9..7645a4005 100644
--- a/applypatch/applypatch.cpp
+++ b/applypatch/applypatch.cpp
@@ -40,10 +40,9 @@
#include "edify/expr.h"
#include "otafault/ota_io.h"
+#include "otautil/cache_location.h"
#include "otautil/print_sha1.h"
-std::string cache_temp_source = "/cache/saved.file";
-
static int LoadPartitionContents(const std::string& filename, FileContents* file);
static size_t FileSink(const unsigned char* data, size_t len, int fd);
static int GenerateTarget(const FileContents& source_file, const std::unique_ptr<Value>& patch,
@@ -404,7 +403,7 @@ int applypatch_check(const char* filename, const std::vector<std::string>& patch
// If the source file is missing or corrupted, it might be because we were killed in the middle
// of patching it. A copy of it should have been made in cache_temp_source. If that file
// exists and matches the sha1 we're looking for, the check still passes.
- if (LoadFileContents(cache_temp_source.c_str(), &file) != 0) {
+ if (LoadFileContents(CacheLocation::location().cache_temp_source().c_str(), &file) != 0) {
printf("failed to load cache file\n");
return 1;
}
@@ -526,7 +525,7 @@ int applypatch(const char* source_filename, const char* target_filename,
printf("source file is bad; trying copy\n");
FileContents copy_file;
- if (LoadFileContents(cache_temp_source.c_str(), &copy_file) < 0) {
+ if (LoadFileContents(CacheLocation::location().cache_temp_source().c_str(), &copy_file) < 0) {
printf("failed to read copy file\n");
return 1;
}
@@ -621,7 +620,7 @@ static int GenerateTarget(const FileContents& source_file, const std::unique_ptr
printf("not enough free space on /cache\n");
return 1;
}
- if (SaveFileContents(cache_temp_source.c_str(), &source_file) < 0) {
+ if (SaveFileContents(CacheLocation::location().cache_temp_source().c_str(), &source_file) < 0) {
printf("failed to back up source file\n");
return 1;
}
@@ -667,7 +666,7 @@ static int GenerateTarget(const FileContents& source_file, const std::unique_ptr
}
// Delete the backup copy of the source.
- unlink(cache_temp_source.c_str());
+ unlink(CacheLocation::location().cache_temp_source().c_str());
// Success!
return 0;