mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-14 18:58:36 +12:00
Improve Trophy Installer robustness
Relax paranoidal mount point locking and temp dir creation mechanism. It was incompatible with a setup where user directory is symlinked. Instead, create temp dir as close to target as possible (see savedata).
This commit is contained in:
parent
56cebd99c2
commit
0ac3dbfec9
2 changed files with 5 additions and 6 deletions
|
@ -23,6 +23,7 @@ namespace vfs
|
||||||
// Functions in this namespace operate on host filepaths, similar to fs::
|
// Functions in this namespace operate on host filepaths, similar to fs::
|
||||||
namespace host
|
namespace host
|
||||||
{
|
{
|
||||||
|
// For internal use (don't use)
|
||||||
std::string hash_path(const std::string& path, const std::string& dev_root);
|
std::string hash_path(const std::string& path, const std::string& dev_root);
|
||||||
|
|
||||||
// Call fs::rename with retry on access error
|
// Call fs::rename with retry on access error
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "Emu/VFS.h"
|
#include "Emu/VFS.h"
|
||||||
#include "Emu/System.h"
|
|
||||||
#include "Emu/Cell/lv2/sys_fs.h"
|
|
||||||
#include "TRP.h"
|
#include "TRP.h"
|
||||||
#include "Crypto/sha1.h"
|
#include "Crypto/sha1.h"
|
||||||
#include "Utilities/StrUtil.h"
|
#include "Utilities/StrUtil.h"
|
||||||
|
@ -25,7 +23,7 @@ bool TRPLoader::Install(const std::string& dest, bool show)
|
||||||
|
|
||||||
const std::string& local_path = vfs::get(dest);
|
const std::string& local_path = vfs::get(dest);
|
||||||
|
|
||||||
const auto temp = vfs::host::hash_path(local_path, Emu.GetHddDir()) + '/';
|
const auto temp = fmt::format(u8"%s.$temp$%u", local_path, __rdtsc());
|
||||||
|
|
||||||
if (!fs::create_dir(temp))
|
if (!fs::create_dir(temp))
|
||||||
{
|
{
|
||||||
|
@ -49,7 +47,7 @@ bool TRPLoader::Install(const std::string& dest, bool show)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the file in the temporary directory
|
// Create the file in the temporary directory
|
||||||
success = fs::write_file(temp + vfs::escape(entry.name), fs::create + fs::excl, buffer);
|
success = fs::write_file(temp + '/' + vfs::escape(entry.name), fs::create + fs::excl, buffer);
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -58,7 +56,7 @@ bool TRPLoader::Install(const std::string& dest, bool show)
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
success = vfs::host::remove_all(local_path, Emu.GetHddDir(), &g_mp_sys_dev_hdd0, true) || !fs::is_dir(local_path);
|
success = fs::remove_all(local_path) || !fs::is_dir(local_path);
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
|
@ -70,7 +68,7 @@ bool TRPLoader::Install(const std::string& dest, bool show)
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
// Remove temporary directory manually on failure (removed automatically on success)
|
// Remove temporary directory manually on failure (removed automatically on success)
|
||||||
auto old_error = fs::g_tls_error;
|
auto old_error = fs::g_tls_error;
|
||||||
fs::remove_all(temp);
|
fs::remove_all(temp);
|
||||||
fs::g_tls_error = old_error;
|
fs::g_tls_error = old_error;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue