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':