Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64f07c5f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove from preloads/file_cache when clearing the cache"

parents a546fef3 f3124d8f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -961,6 +961,10 @@ binder::Status InstalldNativeService::freeCache(const std::unique_ptr<std::strin
            add_cache_files(cache,
                    StringPrintf("%s/Android/data", create_data_media_path(uuid_, user).c_str()));
        }
        // Add files from /data/preloads/file_cache
        if (uuid == nullptr) {
            add_preloads_file_cache(cache, uuid_);
        }
        ATRACE_END();

        ATRACE_BEGIN("clear");
+15 −0
Original line number Diff line number Diff line
@@ -1003,6 +1003,21 @@ void add_cache_files(cache_t* cache, const std::string& data_path) {
    closedir(d);
}

void add_preloads_file_cache(cache_t* cache, const char* volume_uuid) {
    char dirname[PATH_MAX];
    DIR* subdir;
    auto cache_path = StringPrintf("%s/preloads/file_cache", create_data_path(volume_uuid).c_str());
    strcpy(dirname, cache_path.c_str());
    CACHE_NOISY(ALOGI("add_preloads_file_cache: dirname=%s\n", dirname));
    subdir = opendir(dirname);
    if (subdir != NULL) {
        size_t dirnameLen = strlen(dirname);
        _add_cache_files(cache, NULL, dirname, subdir, dirname, dirname + dirnameLen,
                PATH_MAX - dirnameLen);
        closedir(subdir);
    }
}

static char *create_dir_path(char path[PATH_MAX], cache_dir_t* dir)
{
    char *pos = path;
+2 −0
Original line number Diff line number Diff line
@@ -143,6 +143,8 @@ std::string read_path_inode(const std::string& parent, const char* name, const c

void add_cache_files(cache_t* cache, const std::string& data_path);

void add_preloads_file_cache(cache_t* cache, const char* volume_uuid);

void clear_cache_files(const std::string& data_path, cache_t* cache, int64_t free_size);

void finish_cache_collection(cache_t* cache);