mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-27 00:38:58 +02:00
[desktop] fix save data location, orphaned profiles finder (#2678)
Previously, if the user had their NAND in a nonstandard location, profiles.dat would be read from the standard Eden path and thus return effectively garbage data. What this would result in is: - The Qt profile manager would be completely nonfunctional - "Open Save Data Location" would put you into the completely wrong place - Games would read from incorrect locations for their saves To solve this, I made it so that profiles.dat is re-read *after* QtConfig initializes. It's not the perfect solution, but it works. Additionally, this adds an orphaned profiles finder: - walks through the save folders in nand/user/save/000.../ - for each subdirectory, checks to see if profiles.dat contains a corresponding UUID - If not, the profile is "orphaned". It may contain legit save data, so let the user decide how to handle it (famous last words) - Empty profiles are just removed. If they really matter, they're instantly recreated anyways. The orphaned profiles check runs right *after* the decryption keys check, but before the game list ever gets populated Signed-off-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2678 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: MaranBr <maranbr@eden-emu.dev>
This commit is contained in:
parent
6a4fa11ac3
commit
badd913bee
11 changed files with 156 additions and 17 deletions
|
|
@ -1,8 +1,10 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "qt_common/qt_game_util.h"
|
||||
#include "qt_content_util.h"
|
||||
#include "common/fs/fs.h"
|
||||
#include "core/hle/service/acc/profile_manager.h"
|
||||
#include "frontend_common/content_manager.h"
|
||||
#include "frontend_common/firmware_manager.h"
|
||||
#include "qt_common/qt_common.h"
|
||||
|
|
@ -310,4 +312,40 @@ void VerifyInstalledContents() {
|
|||
}
|
||||
}
|
||||
|
||||
void FixProfiles()
|
||||
{
|
||||
// Reset user save files after config is initialized and migration is done.
|
||||
// Doing it at init time causes profiles to read from the wrong place entirely if NAND dir is not default
|
||||
// TODO: better solution
|
||||
system->GetProfileManager().ResetUserSaveFile();
|
||||
std::vector<std::string> orphaned = system->GetProfileManager().FindOrphanedProfiles();
|
||||
|
||||
// no orphaned dirs--all good :)
|
||||
if (orphaned.empty())
|
||||
return;
|
||||
|
||||
// otherwise, let the user know
|
||||
QString qorphaned;
|
||||
|
||||
// max. of 8 orphaned profiles is fair, I think
|
||||
// 33 = 32 (UUID) + 1 (\n)
|
||||
qorphaned.reserve(8 * 33);
|
||||
|
||||
for (const std::string& s : orphaned) {
|
||||
qorphaned += "\n" + QString::fromStdString(s);
|
||||
}
|
||||
|
||||
QtCommon::Frontend::Critical(
|
||||
tr("Orphaned Profiles Detected!"),
|
||||
tr("UNEXPECTED BAD THINGS MAY HAPPEN IF YOU DON'T READ THIS!\n"
|
||||
"Eden has detected the following save directories with no attached profile:\n"
|
||||
"%1\n\n"
|
||||
"Click \"OK\" to open your save folder and fix up your profiles.\n"
|
||||
"Hint: copy the contents of the largest or last-modified folder elsewhere, "
|
||||
"delete all orphaned profiles, and move your copied contents to the good profile.")
|
||||
.arg(qorphaned));
|
||||
|
||||
QtCommon::Game::OpenSaveFolder();
|
||||
}
|
||||
|
||||
} // namespace QtCommon::Content
|
||||
|
|
|
|||
|
|
@ -45,5 +45,8 @@ void InstallKeys();
|
|||
// Content //
|
||||
void VerifyGameContents(const std::string &game_path);
|
||||
void VerifyInstalledContents();
|
||||
|
||||
// Profiles //
|
||||
void FixProfiles();
|
||||
}
|
||||
#endif // QT_CONTENT_UTIL_H
|
||||
|
|
|
|||
|
|
@ -178,6 +178,12 @@ void OpenNANDFolder()
|
|||
OpenEdenFolder(Common::FS::EdenPath::NANDDir);
|
||||
}
|
||||
|
||||
void OpenSaveFolder()
|
||||
{
|
||||
const auto path = Common::FS::GetEdenPath(Common::FS::EdenPath::NANDDir) / "user/save/0000000000000000";
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(QString::fromStdString(path.string())));
|
||||
}
|
||||
|
||||
void OpenSDMCFolder()
|
||||
{
|
||||
OpenEdenFolder(Common::FS::EdenPath::SDMCDir);
|
||||
|
|
@ -379,21 +385,21 @@ void RemoveCacheStorage(u64 program_id)
|
|||
}
|
||||
|
||||
// Metadata //
|
||||
void ResetMetadata()
|
||||
void ResetMetadata(bool show_message)
|
||||
{
|
||||
const QString title = tr("Reset Metadata Cache");
|
||||
|
||||
if (!Common::FS::Exists(Common::FS::GetEdenPath(Common::FS::EdenPath::CacheDir)
|
||||
/ "game_list/")) {
|
||||
QtCommon::Frontend::Warning(rootObject, title, tr("The metadata cache is already empty."));
|
||||
if (show_message) QtCommon::Frontend::Warning(rootObject, title, tr("The metadata cache is already empty."));
|
||||
} else if (Common::FS::RemoveDirRecursively(
|
||||
Common::FS::GetEdenPath(Common::FS::EdenPath::CacheDir) / "game_list")) {
|
||||
QtCommon::Frontend::Information(rootObject,
|
||||
if (show_message) QtCommon::Frontend::Information(rootObject,
|
||||
title,
|
||||
tr("The operation completed successfully."));
|
||||
UISettings::values.is_game_list_reload_pending.exchange(true);
|
||||
} else {
|
||||
QtCommon::Frontend::Warning(
|
||||
if (show_message) QtCommon::Frontend::Warning(
|
||||
rootObject,
|
||||
title,
|
||||
tr("The metadata cache couldn't be deleted. It might be in use or non-existent."));
|
||||
|
|
@ -573,5 +579,4 @@ void CreateHomeMenuShortcut(ShortcutTarget target) {
|
|||
CreateShortcut(game_path, QLaunchId, "Switch Home Menu", target, "-qlaunch", false);
|
||||
}
|
||||
|
||||
|
||||
} // namespace QtCommon::Game
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ bool MakeShortcutIcoPath(const u64 program_id,
|
|||
void OpenEdenFolder(const Common::FS::EdenPath &path);
|
||||
void OpenRootDataFolder();
|
||||
void OpenNANDFolder();
|
||||
void OpenSaveFolder();
|
||||
void OpenSDMCFolder();
|
||||
void OpenModFolder();
|
||||
void OpenLogFolder();
|
||||
|
|
@ -67,7 +68,7 @@ void RemoveCustomConfiguration(u64 program_id, const std::string& game_path);
|
|||
void RemoveCacheStorage(u64 program_id);
|
||||
|
||||
// Metadata //
|
||||
void ResetMetadata();
|
||||
void ResetMetadata(bool show_message = true);
|
||||
|
||||
// Shortcuts //
|
||||
void CreateShortcut(const std::string& game_path,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue