summaryrefslogtreecommitdiffstats
path: root/applypatch/freecache.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-07-13 21:48:45 +0200
committerandroid-build-merger <android-build-merger@google.com>2018-07-13 21:48:45 +0200
commit603b7ed470e98843cd97c31e50e149518616fde0 (patch)
tree81909b18c39e8fa0e37f18d887a0482cef39c50a /applypatch/freecache.cpp
parentMerge "tests: Clean up the temporary dirs post-run." (diff)
parentMerge "applypatch: Consolidate CacheSizeCheck() and MakeFreeSpaceOnCache()." (diff)
downloadandroid_bootable_recovery-603b7ed470e98843cd97c31e50e149518616fde0.tar
android_bootable_recovery-603b7ed470e98843cd97c31e50e149518616fde0.tar.gz
android_bootable_recovery-603b7ed470e98843cd97c31e50e149518616fde0.tar.bz2
android_bootable_recovery-603b7ed470e98843cd97c31e50e149518616fde0.tar.lz
android_bootable_recovery-603b7ed470e98843cd97c31e50e149518616fde0.tar.xz
android_bootable_recovery-603b7ed470e98843cd97c31e50e149518616fde0.tar.zst
android_bootable_recovery-603b7ed470e98843cd97c31e50e149518616fde0.zip
Diffstat (limited to 'applypatch/freecache.cpp')
-rw-r--r--applypatch/freecache.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/applypatch/freecache.cpp b/applypatch/freecache.cpp
index 4989b7496..e4878655e 100644
--- a/applypatch/freecache.cpp
+++ b/applypatch/freecache.cpp
@@ -150,22 +150,22 @@ static int64_t FreeSpaceForFile(const std::string& filename) {
return free_space;
}
-int MakeFreeSpaceOnCache(size_t bytes_needed) {
+bool CheckAndFreeSpaceOnCache(size_t bytes) {
#ifndef __ANDROID__
// TODO(xunchang): Implement a heuristic cache size check during host simulation.
- LOG(WARNING) << "Skipped making (" << bytes_needed
+ LOG(WARNING) << "Skipped making (" << bytes
<< ") bytes free space on /cache; program is running on host";
- return 0;
+ return true;
#endif
std::vector<std::string> dirs{ "/cache", Paths::Get().cache_log_directory() };
for (const auto& dirname : dirs) {
- if (RemoveFilesInDirectory(bytes_needed, dirname, FreeSpaceForFile)) {
- return 0;
+ if (RemoveFilesInDirectory(bytes, dirname, FreeSpaceForFile)) {
+ return true;
}
}
- return -1;
+ return false;
}
bool RemoveFilesInDirectory(size_t bytes_needed, const std::string& dirname,