mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-10-20 18:59:26 +02:00
[common] do not crash when don't have permissions to /tmp/eden directory due to unforessen circumstances (FreeBSD) (#3912)
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:
parent
1f558ce9b3
commit
ee188168c1
3 changed files with 13 additions and 14 deletions
|
|
@ -46,10 +46,10 @@ const std::string GetDataDirString(DataDir dir, const std::string &user_id)
|
||||||
u64 ClearDir(DataDir dir, const std::string &user_id)
|
u64 ClearDir(DataDir dir, const std::string &user_id)
|
||||||
{
|
{
|
||||||
fs::path data_dir = GetDataDir(dir, 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
|
// mkpath at the end just so it actually exists
|
||||||
fs::create_directories(data_dir);
|
fs::create_directories(data_dir, ec);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -181,15 +181,13 @@ void InstallFirmware(const QString& location, bool recursive) {
|
||||||
|
|
||||||
QString UnzipFirmwareToTmp(const QString& location) {
|
QString UnzipFirmwareToTmp(const QString& location) {
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
fs::path tmp{fs::temp_directory_path()};
|
fs::path tmp{fs::temp_directory_path() / "eden" / "firmware"};
|
||||||
|
std::error_code ec;
|
||||||
if (!fs::create_directories(tmp / "eden" / "firmware")) {
|
fs::remove_all(tmp, ec);
|
||||||
|
if (!fs::create_directories(tmp, ec)) {
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp /= "eden";
|
|
||||||
tmp /= "firmware";
|
|
||||||
|
|
||||||
QString qCacheDir = QString::fromStdString(tmp.string());
|
QString qCacheDir = QString::fromStdString(tmp.string());
|
||||||
|
|
||||||
QFile zip(location);
|
QFile zip(location);
|
||||||
|
|
|
||||||
|
|
@ -83,8 +83,9 @@ QStringList GetModFolders(const QString& root, const QString& fallbackName) {
|
||||||
// now make a temp directory...
|
// now make a temp directory...
|
||||||
const auto mod_dir = fs::temp_directory_path() / "eden" / "mod" / name.toStdString();
|
const auto mod_dir = fs::temp_directory_path() / "eden" / "mod" / name.toStdString();
|
||||||
const auto tmp = mod_dir / to_make;
|
const auto tmp = mod_dir / to_make;
|
||||||
fs::remove_all(mod_dir);
|
std::error_code ec;
|
||||||
if (!fs::create_directories(tmp)) {
|
fs::remove_all(mod_dir, ec);
|
||||||
|
if (!fs::create_directories(tmp, ec)) {
|
||||||
LOG_ERROR(Frontend, "Failed to create temporary directory {}", tmp.string());
|
LOG_ERROR(Frontend, "Failed to create temporary directory {}", tmp.string());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
@ -116,9 +117,9 @@ QStringList GetModFolders(const QString& root, const QString& fallbackName) {
|
||||||
const QString ExtractMod(const QString& path) {
|
const QString ExtractMod(const QString& path) {
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
fs::path tmp{fs::temp_directory_path() / "eden" / "unzip_mod"};
|
fs::path tmp{fs::temp_directory_path() / "eden" / "unzip_mod"};
|
||||||
|
std::error_code ec;
|
||||||
fs::remove_all(tmp);
|
fs::remove_all(tmp, ec);
|
||||||
if (!fs::create_directories(tmp)) {
|
if (!fs::create_directories(tmp, ec)) {
|
||||||
QtCommon::Frontend::Critical(tr("Mod Extract Failed"),
|
QtCommon::Frontend::Critical(tr("Mod Extract Failed"),
|
||||||
tr("Failed to create temporary directory %1")
|
tr("Failed to create temporary directory %1")
|
||||||
.arg(QString::fromStdString(tmp.string())));
|
.arg(QString::fromStdString(tmp.string())));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue