Eliminate a pointless multimap in the cache cleaner
This commit is contained in:
parent
51b92390b6
commit
77ecff1cba
1 changed files with 7 additions and 2 deletions
|
@ -165,10 +165,11 @@ void CleanCache(agi::fs::path const& directory, std::string const& file_type, ui
|
|||
queue->Async([=]{
|
||||
LOG_D("utils/clean_cache") << "cleaning " << directory/file_type;
|
||||
uint64_t total_size = 0;
|
||||
std::multimap<int64_t, agi::fs::path> cachefiles;
|
||||
using cache_item = std::pair<int64_t, agi::fs::path>;
|
||||
std::vector<cache_item> cachefiles;
|
||||
for (auto const& file : agi::fs::DirectoryIterator(directory, file_type)) {
|
||||
agi::fs::path path = directory/file;
|
||||
cachefiles.insert({agi::fs::ModifiedTime(path), path});
|
||||
cachefiles.push_back({agi::fs::ModifiedTime(path), path});
|
||||
total_size += agi::fs::Size(path);
|
||||
}
|
||||
|
||||
|
@ -178,6 +179,10 @@ void CleanCache(agi::fs::path const& directory, std::string const& file_type, ui
|
|||
return;
|
||||
}
|
||||
|
||||
sort(begin(cachefiles), end(cachefiles), [](cache_item const& a, cache_item const& b) {
|
||||
return a.first < b.first;
|
||||
});
|
||||
|
||||
int deleted = 0;
|
||||
for (auto const& i : cachefiles) {
|
||||
// stop cleaning?
|
||||
|
|
Loading…
Reference in a new issue