From d5fbcc1ba9f5ff81ca67e80b552ee02d285ef536 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Wed, 11 Apr 2018 14:38:09 -0700 Subject: Remove the old log files if cache space is insufficient for OTA We set the limit of the max stash size to 80% of cache size. But the cache space can still be insufficient for the update if the log files occupy a large chunk of /cache. So remove the old logs for now to make room for the update. Bug: 77528881 Test: unit tests pass Change-Id: Ia8bcb0ace11f8164ad9290bfb360e08e31d282cb --- applypatch/include/applypatch/applypatch.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'applypatch/include') diff --git a/applypatch/include/applypatch/applypatch.h b/applypatch/include/applypatch/applypatch.h index 912ead1fa..021a28d05 100644 --- a/applypatch/include/applypatch/applypatch.h +++ b/applypatch/include/applypatch/applypatch.h @@ -39,7 +39,7 @@ using SinkFn = std::function; // applypatch.cpp int ShowLicenses(); -size_t FreeSpaceForFile(const char* filename); +size_t FreeSpaceForFile(const std::string& filename); int CacheSizeCheck(size_t bytes); int ParseSha1(const char* str, uint8_t* digest); @@ -79,5 +79,9 @@ int ApplyImagePatch(const unsigned char* old_data, size_t old_size, const Value& // freecache.cpp int MakeFreeSpaceOnCache(size_t bytes_needed); +// Removes the files in |dirname| until we have at least |bytes_needed| bytes of free space on +// the partition. The size of the free space is returned by calling |space_checker|. +bool RemoveFilesInDirectory(size_t bytes_needed, const std::string& dirname, + const std::function& space_checker); #endif -- cgit v1.2.3