Avoid creating redundant temporary file list

PR #20863.
This commit is contained in:
Chocobo1 2024-05-29 12:29:48 +08:00 committed by sledgehammer999
parent 0246df790a
commit 318a677e8f
No known key found for this signature in database
GPG key ID: 6E4A2D025B7CC9A2

View file

@ -37,6 +37,7 @@
#include <QCoreApplication>
#include <QDebug>
#include <QDir>
#include <QDirIterator>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
@ -1159,8 +1160,11 @@ void AppController::getDirectoryContentAction()
throw APIError(APIErrorType::BadParams, tr("Invalid mode, allowed values: %1").arg(u"all, dirs, files"_s));
};
const QStringList dirs = dir.entryList(QDir::NoDotAndDotDot | parseDirectoryContentMode(visibility));
setResult(QJsonArray::fromStringList(dirs));
QJsonArray ret;
QDirIterator it {dirPath, (QDir::NoDotAndDotDot | parseDirectoryContentMode(visibility))};
while (it.hasNext())
ret.append(it.next());
setResult(ret);
}
void AppController::networkInterfaceListAction()