From e7ddc647f39ffff6261e634671a6a4e0cff00e6c Mon Sep 17 00:00:00 2001 From: crueter Date: Fri, 27 Jun 2025 06:03:19 +0000 Subject: [PATCH] [desktop] Fix migration options (#220) Signed-off-by: crueter Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/220 Co-authored-by: crueter Co-committed-by: crueter --- src/yuzu/migration_worker.cpp | 37 +++++++++++++++++++++++--------- src/yuzu/migration_worker.h | 3 +++ src/yuzu/user_data_migration.cpp | 11 ++++++---- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/yuzu/migration_worker.cpp b/src/yuzu/migration_worker.cpp index 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 #include #include #include +#include #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: copy fs::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 WIN32 if (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); } +#endif success_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.h index 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_H diff --git a/src/yuzu/user_data_migration.cpp b/src/yuzu/user_data_migration.cpp index 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; }