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.
This commit is contained in:
Nekotekina 2020-04-12 00:47:58 +03:00
parent 17f3a114be
commit 5524cd1e75

View file

@ -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<u8>() == static_cast<fs::container_stream<std::vector<u8>>*>(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<u8>());
break;
if (file)
{
file.write(static_cast<fs::container_stream<std::vector<u8>>*>(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':