[common] do not crash when don't have permissions to /tmp/eden directory due to unforessen circumstances (FreeBSD) (#3912)
Some checks are pending
tx-src / sources (push) Waiting to run
Check Strings / check-strings (push) Waiting to run

instead of throwing, use std::error_code and such

due to reasons unberknownst to me, the UID of the /tmp/eden directory was set for another user, this inevitably caused a crash due to wrong permissions (which is a very user unfriendly thing to do generally)

Signed-off-by: lizzie <lizzie@eden-emu.dev>

Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3912
Reviewed-by: crueter <crueter@eden-emu.dev>
This commit is contained in:
lizzie 2026-05-13 19:14:59 +02:00 committed by crueter
parent 1f558ce9b3
commit ee188168c1
No known key found for this signature in database
GPG key ID: 425ACD2D4830EBC6
3 changed files with 13 additions and 14 deletions

View file

@ -46,10 +46,10 @@ const std::string GetDataDirString(DataDir dir, const std::string &user_id)
u64 ClearDir(DataDir dir, const std::string &user_id)
{
fs::path data_dir = GetDataDir(dir, user_id);
u64 result = fs::remove_all(data_dir);
std::error_code ec;
u64 result = fs::remove_all(data_dir, ec);
// mkpath at the end just so it actually exists
fs::create_directories(data_dir);
fs::create_directories(data_dir, ec);
return result;
}