ask user if he wants to delete saves on modpack update

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2026-01-04 03:09:12 +02:00
parent 437242169d
commit 0b26d24c9b
No known key found for this signature in database
GPG key ID: 55EF5DA53DB36318
6 changed files with 48 additions and 30 deletions

View file

@ -3,6 +3,7 @@
#include <QDebug>
#include <QFile>
#include "InstanceTask.h"
#include "minecraft/MinecraftLoadAndCheck.h"
#include "tasks/SequentialTask.h"
@ -61,7 +62,7 @@ void InstanceCreationTask::executeTask()
setStatus(tr("Removing old conflicting files..."));
qDebug() << "Removing old files";
for (const QString& path : m_files_to_remove) {
for (const QString& path : m_filesToRemove) {
if (!QFile::exists(path))
continue;
@ -108,3 +109,27 @@ void InstanceCreationTask::executeTask()
m_gameFilesTask->start();
}
}
void InstanceCreationTask::scheduleToDelete(QWidget* parent, QDir dir, QString path, bool checkDisabled)
{
if (path.isEmpty()) {
return;
}
if (path.startsWith("saves/")) {
if (m_shouldDeleteSaves == ShouldDeleteSaves::NotAsked) {
m_shouldDeleteSaves = askIfShouldDeleteSaves(parent);
}
if (m_shouldDeleteSaves == ShouldDeleteSaves::No) {
return;
}
}
qDebug() << "Scheduling" << path << "for removal";
m_filesToRemove.append(dir.absoluteFilePath(path));
if (checkDisabled) {
if (path.endsWith(".disabled")) { // remove it if it was enabled/disabled by user
m_filesToRemove.append(dir.absoluteFilePath(path.chopped(9)));
} else {
m_filesToRemove.append(dir.absoluteFilePath(path + ".disabled"));
}
}
}