Changeset 774 for trunk/src/network/access
- Timestamp:
- Aug 3, 2010, 3:18:00 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/network/access/qnetworkdiskcache.cpp
r769 r774 512 512 QDirIterator it(cacheDirectory(), filters, QDirIterator::Subdirectories); 513 513 514 QMultiMap<QDateTime, QString> cacheItems; 514 // performance tweak: we store the size together with the name in 515 // order to avoid querying the size again before the file is deleted 516 typedef QPair<QString, qint64> ExpireInfo; 517 518 QMultiMap<QDateTime, ExpireInfo> cacheItems; 515 519 qint64 totalSize = 0; 516 520 while (it.hasNext()) { … … 519 523 QString fileName = info.fileName(); 520 524 if (fileName.endsWith(CACHE_POSTFIX) && fileName.startsWith(CACHE_PREFIX)) { 521 cacheItems.insert(info.created(), path); 522 totalSize += info.size(); 525 ExpireInfo item = qMakePair(path, info.size()); 526 cacheItems.insert(info.created(), item); 527 totalSize += item.second; 523 528 } 524 529 } … … 526 531 int removedFiles = 0; 527 532 qint64 goal = (maximumCacheSize() * 9) / 10; 528 QMultiMap<QDateTime, QString>::const_iterator i = cacheItems.constBegin();533 QMultiMap<QDateTime, >::const_iterator i = cacheItems.constBegin(); 529 534 while (i != cacheItems.constEnd()) { 530 535 if (totalSize < goal) 531 536 break; 532 QString name = i.value(); 533 QFile file(name); 534 qint64 size = file.size(); 535 file.remove(); 536 totalSize -= size; 537 const ExpireInfo &item = i.value(); 538 QFile::remove(item.first); 539 totalSize -= item.second; 537 540 ++removedFiles; 538 541 ++i;
Note:
See TracChangeset
for help on using the changeset viewer.