Readd removing of unmodified cache files (#2947)

Co-authored-by: Mm2PL <mm2pl+gh@kotmisia.pl>
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Tal Neoran 2021-07-03 14:40:24 +03:00 committed by GitHub
parent 8385d06369
commit 6830e8b01b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View file

@ -4,6 +4,7 @@
- Minor: Channel name in `<channel> has gone offline. Exiting host mode.` messages is now clickable. (#2922) - Minor: Channel name in `<channel> has gone offline. Exiting host mode.` messages is now clickable. (#2922)
- Minor: Added `/openurl` command. Usage: `/openurl <URL>`. Opens the provided URL in the browser. (#2461, #2926) - Minor: Added `/openurl` command. Usage: `/openurl <URL>`. Opens the provided URL in the browser. (#2461, #2926)
- Bugfix: Now deleting cache files that weren't modified in the past 14 days. (#2947)
- Bugfix: Fixed large timeout durations in moderation buttons overlapping with usernames or other buttons. (#2865, #2921) - Bugfix: Fixed large timeout durations in moderation buttons overlapping with usernames or other buttons. (#2865, #2921)
- Bugfix: Fix bad behavior of the HTML color picker edit when user input is being entered. (#2942) - Bugfix: Fix bad behavior of the HTML color picker edit when user input is being entered. (#2942)

View file

@ -145,17 +145,17 @@ namespace {
// improved in the future. // improved in the future.
void clearCache(const QDir &dir) void clearCache(const QDir &dir)
{ {
qCDebug(chatterinoCache) << "[Cache] cleared cache"; int deletedCount = 0;
QStringList toBeRemoved;
for (auto &&info : dir.entryInfoList(QDir::Files)) for (auto &&info : dir.entryInfoList(QDir::Files))
{ {
if (info.lastModified().addDays(14) < QDateTime::currentDateTime()) if (info.lastModified().addDays(14) < QDateTime::currentDateTime())
{ {
toBeRemoved << info.absoluteFilePath(); bool res = QFile(info.absoluteFilePath()).remove();
if (res)
++deletedCount;
} }
} }
qCDebug(chatterinoCache) << "Deleted" << deletedCount << "files";
} }
} // namespace } // namespace