Ask before deleting saves as part of a Modpack update (#4622)

This commit is contained in:
Alexandru Ionut Tripon 2026-03-10 10:25:37 +00:00 committed by GitHub
commit 7bef408598
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 48 additions and 30 deletions

View file

@ -35,6 +35,7 @@
#include "FlameInstanceCreationTask.h"
#include "InstanceTask.h"
#include "QObjectPtr.h"
#include "minecraft/mod/tasks/LocalResourceUpdateTask.h"
#include "modplatform/flame/FileResolvingTask.h"
@ -170,10 +171,7 @@ bool FlameCreationTask::updateInstance()
// FIXME: We may want to do something about disabled mods.
auto old_overrides = Override::readOverrides("overrides", old_index_folder);
for (const auto& entry : old_overrides) {
if (entry.isEmpty())
continue;
qDebug() << "Scheduling" << entry << "for removal";
m_files_to_remove.append(old_minecraft_dir.absoluteFilePath(entry));
scheduleToDelete(m_parent, old_minecraft_dir, entry);
}
// Remove remaining old files (we need to do an API request to know which ids are which files...)
@ -224,13 +222,7 @@ bool FlameCreationTask::updateInstance()
continue;
QString relative_path(FS::PathCombine(file.targetFolder, file.version.fileName));
qDebug() << "Scheduling" << relative_path << "for removal";
m_files_to_remove.append(old_minecraft_dir.absoluteFilePath(relative_path));
if (relative_path.endsWith(".disabled")) { // remove it if it was enabled/disabled by user
m_files_to_remove.append(old_minecraft_dir.absoluteFilePath(relative_path.chopped(9)));
} else {
m_files_to_remove.append(old_minecraft_dir.absoluteFilePath(relative_path + ".disabled"));
}
scheduleToDelete(m_parent, old_minecraft_dir, relative_path, true);
}
});
connect(job.get(), &Task::failed, this, [](QString reason) { qCritical() << "Failed to get files:" << reason; });

View file

@ -115,15 +115,7 @@ bool ModrinthCreationTask::updateInstance()
// so we're fine removing them!
if (!old_files.empty()) {
for (auto const& file : old_files) {
if (file.path.isEmpty())
continue;
qDebug() << "Scheduling" << file.path << "for removal";
m_files_to_remove.append(old_minecraft_dir.absoluteFilePath(file.path));
if (file.path.endsWith(".disabled")) { // remove it if it was enabled/disabled by user
m_files_to_remove.append(old_minecraft_dir.absoluteFilePath(file.path.chopped(9)));
} else {
m_files_to_remove.append(old_minecraft_dir.absoluteFilePath(file.path + ".disabled"));
}
scheduleToDelete(m_parent, old_minecraft_dir, file.path, true);
}
}
@ -132,18 +124,12 @@ bool ModrinthCreationTask::updateInstance()
// FIXME: We may want to do something about disabled mods.
auto old_overrides = Override::readOverrides("overrides", old_index_folder);
for (const auto& entry : old_overrides) {
if (entry.isEmpty())
continue;
qDebug() << "Scheduling" << entry << "for removal";
m_files_to_remove.append(old_minecraft_dir.absoluteFilePath(entry));
scheduleToDelete(m_parent, old_minecraft_dir, entry);
}
auto old_client_overrides = Override::readOverrides("client-overrides", old_index_folder);
for (const auto& entry : old_client_overrides) {
if (entry.isEmpty())
continue;
qDebug() << "Scheduling" << entry << "for removal";
m_files_to_remove.append(old_minecraft_dir.absoluteFilePath(entry));
scheduleToDelete(m_parent, old_minecraft_dir, entry);
}
} else {
// We don't have an old index file, so we may duplicate stuff!