|
@@ -1,6 +1,7 @@
|
|
|
#include "patchlist.h"
|
|
|
|
|
|
#include <QDebug>
|
|
|
+#include <QDirIterator>
|
|
|
|
|
|
PatchList::PatchList(LotroDatManager *mgr, QObject *parent) : QObject(parent)
|
|
|
{
|
|
@@ -220,6 +221,7 @@ void PatchList::onPatchOperationFinished(Patch::Operation, Patch*)
|
|
|
{
|
|
|
--active_operations_num_;
|
|
|
if (active_operations_num_ == 0) {
|
|
|
+ cleanUpPatchDirectory();
|
|
|
emit patchOperationsFinished();
|
|
|
}
|
|
|
}
|
|
@@ -253,9 +255,52 @@ void PatchList::forceInstallPatches()
|
|
|
};
|
|
|
|
|
|
for (const QString& db_name : QStringList(
|
|
|
- {"text", "font", "image", "loadscreen",
|
|
|
- "texture", "sound", "video", "micro"})) {
|
|
|
+ {"text", "font", "image", "loadscreen", "texture", "sound", "video", "micro"})) {
|
|
|
Settings::setValue("DatabaseNeedInstall/" + db_name, is_database_enabled(db_name));
|
|
|
}
|
|
|
+
|
|
|
update();
|
|
|
}
|
|
|
+
|
|
|
+void PatchList::cleanUpPatchDirectory()
|
|
|
+{
|
|
|
+ QStringList databases_filenames;
|
|
|
+
|
|
|
+ QSettings settings;
|
|
|
+ settings.beginGroup("PatchDatabases/");
|
|
|
+ qDebug() << "cleanUpPatchDirectory: Iterating through groups: " << settings.childGroups();
|
|
|
+
|
|
|
+ for (const QString& key : settings.childGroups()) {
|
|
|
+ settings.beginGroup(key);
|
|
|
+ QString filename = settings.value("path").toString();
|
|
|
+ if (!filename.isEmpty()) {
|
|
|
+ databases_filenames << filename;
|
|
|
+ }
|
|
|
+ settings.endGroup();
|
|
|
+ }
|
|
|
+ settings.endGroup();
|
|
|
+
|
|
|
+ QDirIterator patch_dir_iterator(
|
|
|
+ Settings::getValue("General/PatchDownloadDir").toString(),
|
|
|
+ QDir::NoDotAndDotDot | QDir::Files,
|
|
|
+ QDirIterator::Subdirectories
|
|
|
+ );
|
|
|
+
|
|
|
+ while (patch_dir_iterator.hasNext()) {
|
|
|
+ qDebug() << "cleanUpPatchDirectory: found " << patch_dir_iterator.next();
|
|
|
+ bool is_file_actual = false;
|
|
|
+ for (const QString& file_path : databases_filenames) {
|
|
|
+ if (QFileInfo(file_path) == patch_dir_iterator.fileInfo()) {
|
|
|
+ is_file_actual = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!is_file_actual) {
|
|
|
+ qDebug() << "cleanUpPatchDirectory: file" << patch_dir_iterator.filePath()
|
|
|
+ << "is not in patch list. Removing";
|
|
|
+
|
|
|
+ QFile::remove(patch_dir_iterator.filePath());
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|