From 5524cd1e757ef0a57dd896c6c5bc0e8fc6b8952f Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sun, 12 Apr 2020 00:47:58 +0300 Subject: [PATCH] Improve TAR loader Don't overwrite unchanged files. Print error if failed to overwrite. This commit affects PS3 firmware installation. Trying to workaround a bug where some files cannot be overwritten. --- rpcs3/Loader/TAR.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/rpcs3/Loader/TAR.cpp b/rpcs3/Loader/TAR.cpp index 61849c39f6..2d829c59b8 100644 --- a/rpcs3/Loader/TAR.cpp +++ b/rpcs3/Loader/TAR.cpp @@ -114,9 +114,29 @@ bool tar_object::extract(std::string path, std::string ignore) { case '0': { + auto data = get_file(header.name).release(); + + if (fs::file prev{result}) + { + if (prev.to_vector() == static_cast>*>(data.get())->obj) + { + // Workaround: avoid overwriting existing data if it's the same. + tar_log.notice("TAR Loader: skipped existing file %s", header.name); + break; + } + } + fs::file file(result, fs::rewrite); - file.write(get_file(header.name).to_vector()); - break; + + if (file) + { + file.write(static_cast>*>(data.get())->obj); + tar_log.notice("TAR Loader: written file %s", header.name); + break; + } + + tar_log.error("TAR Loader: failed to write file %s (%s)", header.name, fs::g_tls_error); + return false; } case '5':