Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning on cemu flatpak for when you use a Custom MLC path without filesystem permissions #1439

Open
nonameVHSM opened this issue Dec 4, 2024 · 3 comments
Labels
feature request New feature or request

Comments

@nonameVHSM
Copy link

Your suggestion

This falls under a niche feature but I believe it's a worthwhile addition. Recently I switched to the cemu flatpak and I set a custom MLC path pointing to my old MLC folder location, but I forgot to give cemu flatpak write permissions with filesystem access. I played a game for a few hours, saved my progress and closed cemu, when I came back the next day my new saves were gone, with only the old saves remaining, I was very confused but after some testing I realized what was happening.

My suggestion is to add a warning for when you're using a cemu flatpak and it doesn't have write access to that folder so this issue doesn't happen. Similar to the warnings you already get when changing the MLC path:

void GeneralSettings2::OnMLCPathSelect(wxCommandEvent& event)
{
if(CafeSystem::IsTitleRunning())
{
wxMessageBox(_("Can't change MLC path while a game is running!"), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this);
return;
}
// show directory dialog
wxDirDialog path_dialog(this, _("Select MLC directory"), wxEmptyString, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
if (path_dialog.ShowModal() != wxID_OK || path_dialog.GetPath().empty())
return;
// check if the choosen MLC path is an already initialized MLC location
fs::path newMlc = wxHelper::MakeFSPath(path_dialog.GetPath());
if(CemuApp::CheckMLCPath(newMlc))
{
// ask user if they are sure they want to use this folder and let them know that accounts and saves wont transfer
wxString message = _("Note that changing the MLC location will not transfer any accounts or save files. Are you sure you want to change the path?");
wxMessageDialog dialog(this, message, _("Warning"), wxYES_NO | wxCENTRE | wxICON_WARNING);
if(dialog.ShowModal() == wxID_NO)
return;
if( !CemuApp::CreateDefaultMLCFiles(newMlc) ) // creating also acts as a check for read+write access
{
wxMessageBox(_("Failed to create default MLC files in the selected directory. The MLC path has not been changed"), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this);
return;
}
}
else
{
// ask user if they want to create a new mlc structure at the choosen location
wxString message = _("The selected directory does not contain the expected MLC structure. Do you want to create a new MLC structure in this directory?\nNote that changing the MLC location will not transfer any accounts or save files.");
wxMessageDialog dialog(this, message, _("Warning"), wxYES_NO | wxCENTRE | wxICON_WARNING);
if( !CemuApp::CreateDefaultMLCFiles(newMlc) )
{
wxMessageBox(_("Failed to create default MLC files in the selected directory. The MLC path has not been changed"), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this);
return;
}
}
// update MLC path and store any other modified settings
GetConfig().SetMLCPath(newMlc);
StoreConfig();
wxMessageBox(_("Cemu needs to be restarted for the changes to take effect."), _("Information"), wxOK | wxCENTRE | wxICON_INFORMATION, this);
// close settings and then cemu
wxCloseEvent closeEvent(wxEVT_CLOSE_WINDOW);
wxPostEvent(this, closeEvent);
wxPostEvent(GetParent(), closeEvent);
}

Warn the user that cemu flatpak doesn't have write access to that location, ask them to give it write access and ask them if they're sure they want to use that location as the custom MLC path. Or just refuse to change the custom path to that location until the user gives cemu write permissions like some other flatpaks do.

I believe the MLC folder is the only thing that the user can put outside of the flatpak sandbox that needs write access, but if there are others my idea would be to have the same warning.

@nonameVHSM nonameVHSM added the feature request New feature or request label Dec 4, 2024
@Exzap
Copy link
Member

Exzap commented Dec 4, 2024

There is already code for this. In the snippet you posted there is this check. There is a similar check each time you start Cemu and it should show an error message if it can't write to MLC. So maybe the check doesn't work correctly for some reason. I was able to replicate this on Windows by making the mlc folder partially read-only and it would just silently ignore it instead of showing the error. I'll look deeper into this when I have some spare time

There is also a secondary problem of the flatpak version not granting write access, but I am not sure if this is due to wxWidgets not properly supporting portals.

@nonameVHSM
Copy link
Author

nonameVHSM commented Dec 4, 2024

There is already code for this. In the snippet you posted there is this check. There is a similar check each time you start Cemu and it should show an error message if it can't write to MLC. So maybe the check doesn't work correctly for some reason. I was able to replicate this on Windows by making the mlc folder partially read-only and it would just silently ignore it instead of showing the error. I'll look deeper into this when I have some spare time

Thank you for the response, I see I didn't notice that check, but I tested it and it is working:
Screenshot from 2024-12-04 16-15-39

The reason the check fails to stop the issue I mentioned is because it only checks on folder creation, if it's unable to create the folder because it doesn't have write access then errors out as intended. But if the MLC folder already exists and already has the proper structure from a previous cemu installation for example, then there is not code to stop it from using that folder.

The same check happens later but for when the MLC folder exists bust it has incorrect file structure/the folder is empty, but it doesn't stop anything if the file structure is correct.

if( !CemuApp::CreateDefaultMLCFiles(newMlc) )
{
wxMessageBox(_("Failed to create default MLC files in the selected directory. The MLC path has not been changed"), _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this);
return;
}

@Exzap
Copy link
Member

Exzap commented Dec 7, 2024

934cb54 adds a dummy write to see if it can actually write to MLC. Checked each time Cemu launches. It will take a while until this arrives on flathub, so I'll leave the issue open for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants