Compare commits

...

4 Commits

Author SHA1 Message Date
crueter
1b3359a1d7 Windows fix (again)
Signed-off-by: crueter <swurl@swurl.xyz>
2025-06-26 17:01:52 -04:00
crueter
0575caa8df license headers, windows fixed
Signed-off-by: crueter <swurl@swurl.xyz>
2025-06-26 16:29:29 -04:00
crueter
10567bc6d4 verbosity
Signed-off-by: crueter <swurl@swurl.xyz>
2025-06-26 15:37:50 -04:00
crueter
283dfb4e72 [desktop] Fix migration options
Signed-off-by: crueter <swurl@swurl.xyz>
2025-06-26 15:30:59 -04:00
3 changed files with 36 additions and 13 deletions

View File

@@ -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: 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;
}

View File

@@ -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

View File

@@ -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;
}