VERY experimental Nintendo Switch 2 emulator
C++
[desktop] Fix migration options (#220)
cruetere7ddc647f39f
diff --git a/src/yuzu/migration_worker.cpp b/src/yuzu/migration_worker.cppindex bd96fec5de..42ec006026 100644--- a/src/yuzu/migration_worker.cpp+++ b/src/yuzu/migration_worker.cpp@@ -1,9 +1,13 @@+// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project+// SPDX-License-Identifier: GPL-3.0-or-later+#include "migration_worker.h"#include <QMap>#include <boost/algorithm/string/predicate.hpp>#include <boost/algorithm/string/replace.hpp>#include <filesystem>+#include <qdebug.h>#include "common/fs/path_util.h"@@ -19,16 +23,17 @@ MigrationWorker::MigrationWorker(const Emulator selected_legacy_emu_,void MigrationWorker::process(){namespace fs = std::filesystem;- const auto copy_options = fs::copy_options::update_existing | fs::copy_options::recursive;+ constexpr auto copy_options = fs::copy_options::update_existing | fs::copy_options::recursive;- std::string legacy_user_dir = selected_legacy_emu.get_user_dir();- std::string legacy_config_dir = selected_legacy_emu.get_config_dir();- std::string legacy_cache_dir = selected_legacy_emu.get_cache_dir();+ const fs::path legacy_user_dir = selected_legacy_emu.get_user_dir();+ const fs::path legacy_config_dir = selected_legacy_emu.get_config_dir();+ const fs::path legacy_cache_dir = selected_legacy_emu.get_cache_dir();- fs::path eden_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::EdenDir);- fs::path config_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::ConfigDir);- fs::path cache_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::CacheDir);- fs::path shader_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::ShaderDir);+ // TODO(crueter): Make these constexpr since they're defaulted+ const fs::path eden_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::EdenDir);+ const fs::path config_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::ConfigDir);+ const fs::path cache_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::CacheDir);+ const fs::path shader_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::ShaderDir);try {fs::remove_all(eden_dir);@@ -61,6 +66,14 @@ void MigrationWorker::process()fs::create_directory_symlink(legacy_cache_dir, cache_dir);}#endif++ success_text.append(tr("\n\nNote that your configuration and data will be shared with %1.\n"+ "If this is not desirable, delete the following files:\n%2\n%3\n%4")+ .arg(tr(selected_legacy_emu.name),+ QString::fromStdString(eden_dir.string()),+ QString::fromStdString(config_dir.string()),+ QString::fromStdString(cache_dir.string())));+break;case MigrationStrategy::Move:// Rename directories if deletion is requested (achieves the same result)@@ -83,6 +96,9 @@ void MigrationWorker::process()// Default behavior: copyfs::copy(legacy_user_dir, eden_dir, copy_options);+// Windows doesn't need any more copies, because cache and config+// are already children of the root directory+#ifndef WIN32if (fs::is_directory(legacy_config_dir)) {fs::copy(legacy_config_dir, config_dir, copy_options);}@@ -90,11 +106,12 @@ void MigrationWorker::process()if (fs::is_directory(legacy_cache_dir)) {fs::copy(legacy_cache_dir, cache_dir, copy_options);}+#endifsuccess_text.append(tr("\n\nIf you wish to clean up the files which were left in the old ""data location, you can do so by deleting the following directory:\n""%1")- .arg(QString::fromStdString(legacy_user_dir)));+ .arg(QString::fromStdString(legacy_user_dir.string())));break;}@@ -104,5 +121,5 @@ void MigrationWorker::process()fs::create_directory(shader_dir);}- emit finished(success_text, legacy_user_dir);+ emit finished(success_text, legacy_user_dir.string());}diff --git a/src/yuzu/migration_worker.h b/src/yuzu/migration_worker.hindex 205e552a94..4d678e7751 100644--- a/src/yuzu/migration_worker.h+++ b/src/yuzu/migration_worker.h@@ -1,3 +1,6 @@+// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project+// SPDX-License-Identifier: GPL-3.0-or-later+#ifndef MIGRATION_WORKER_H#define MIGRATION_WORKER_Hdiff --git a/src/yuzu/user_data_migration.cpp b/src/yuzu/user_data_migration.cppindex 7424fc2c44..df6b7be434 100644--- a/src/yuzu/user_data_migration.cpp+++ b/src/yuzu/user_data_migration.cpp@@ -85,9 +85,11 @@ void UserDataMigrator::ShowMigrationPrompt(QMainWindow *main_window)BUTTON(QCheckBox, clear_shaders, "Clear Shader Cache", clear_shader_tooltip, true)+ u32 id = 0;+#define RADIO(name, text, tooltip, checkState) \BUTTON(QRadioButton, name, text, tooltip, checkState) \- group->addButton(name);+ group->addButton(name, ++id);RADIO(keep_old, "Keep Old Data", keep_old_data_tooltip, true)RADIO(clear_old, "Clear Old Data", clear_old_data_tooltip, false)@@ -136,16 +138,17 @@ void UserDataMigrator::ShowMigrationPrompt(QMainWindow *main_window)}MigrationWorker::MigrationStrategy strategy;+switch (group->checkedId()) {default:[[fallthrough]];- case 0:+ case 1:strategy = MigrationWorker::MigrationStrategy::Copy;break;- case 1:+ case 2:strategy = MigrationWorker::MigrationStrategy::Move;break;- case 2:+ case 3:strategy = MigrationWorker::MigrationStrategy::Link;break;}