mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 13:15:18 -05:00
rbutil: Fix cache size calculation.
We're using Qt's caching mechanism since long, which uses subfolders, so we need to recursively traverse that to get the size of the cache folder. Change-Id: I8425016f60d0575013110e708b539833a8098246
This commit is contained in:
parent
65d0867a25
commit
ec01c57022
3 changed files with 16 additions and 6 deletions
|
|
@ -1046,3 +1046,17 @@ bool Utils::ejectDevice(QString device)
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
qint64 Utils::recursiveFolderSize(QString path)
|
||||
{
|
||||
qint64 size = 0;
|
||||
QList<QFileInfo> items = QDir(path).entryInfoList(QDir::Files | QDir::NoDotAndDotDot);
|
||||
for (auto item: items) {
|
||||
size += item.size();
|
||||
}
|
||||
QList<QString> folders = QDir(path).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for (auto folder: folders) {
|
||||
size += recursiveFolderSize(path + "/" + folder);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ public:
|
|||
static QMap<QString, QList<int> > findRunningProcess(QStringList names);
|
||||
static QList<int> suspendProcess(QList<int> pidlist, bool suspend);
|
||||
static bool ejectDevice(QString device);
|
||||
static qint64 recursiveFolderSize(QString path);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -306,12 +306,7 @@ void Config::setUserSettings()
|
|||
|
||||
void Config::updateCacheInfo(QString path)
|
||||
{
|
||||
QList<QFileInfo> fs;
|
||||
fs = QDir(path + "/rbutil-cache/").entryInfoList(QDir::Files | QDir::NoDotAndDotDot);
|
||||
qint64 sz = 0;
|
||||
for(int i = 0; i < fs.size(); i++) {
|
||||
sz += fs.at(i).size();
|
||||
}
|
||||
qint64 sz = Utils::recursiveFolderSize(path + "/rbutil-cache");
|
||||
ui.cacheSize->setText(tr("Current cache size is %L1 kiB.")
|
||||
.arg(sz/1024));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue