From 7e39b0620a04a1dd806683c4598d69032d1ae32a Mon Sep 17 00:00:00 2001 From: 13xforever Date: Sun, 29 May 2022 00:04:01 +0500 Subject: [PATCH] in case of disc read errors mark dump as broken --- Ps3DiscDumper/Decrypter.cs | 2 +- Ps3DiscDumper/Dumper.cs | 6 +++++- UI.WinForms.Msil/Forms/MainForm.cs | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Ps3DiscDumper/Decrypter.cs b/Ps3DiscDumper/Decrypter.cs index 9a97a70..2abcc80 100644 --- a/Ps3DiscDumper/Decrypter.cs +++ b/Ps3DiscDumper/Decrypter.cs @@ -101,7 +101,7 @@ public Decrypter(Stream fileStream, Stream discStream, byte[] decryptionKey, lon SectorPosition = startSector; } - public override int Read( byte[] buffer, int offset, int count) + public override int Read(byte[] buffer, int offset, int count) { if (Position == inputStream.Length) return 0; diff --git a/Ps3DiscDumper/Dumper.cs b/Ps3DiscDumper/Dumper.cs index 641a4a9..8b51053 100644 --- a/Ps3DiscDumper/Dumper.cs +++ b/Ps3DiscDumper/Dumper.cs @@ -22,7 +22,7 @@ namespace Ps3DiscDumper { public class Dumper: IDisposable { - public const string Version = "3.2.2"; + public const string Version = "3.2.3"; private static readonly HashSet InvalidChars = new(Path.GetInvalidFileNameChars().Concat(Path.GetInvalidPathChars())); private static readonly char[] MultilineSplit = {'\r', '\n'}; @@ -528,6 +528,7 @@ select v.Files[file.TargetFileName].Hashes Decrypter = decrypter; await decrypter.CopyToAsync(outputStream, 8 * 1024 * 1024, Cts.Token).ConfigureAwait(false); await outputStream.FlushAsync(); + error = false; var resultHashes = decrypter.GetHashes(); var resultMd5 = resultHashes["MD5"]; @@ -560,6 +561,8 @@ select v.Files[file.TargetFileName].Hashes { Log.Error(e, e.Message); error = true; + if (tries == 0) + BrokenFiles.Add((file.TargetFileName, "failed to read")); } } while (error && tries > 0 && !Cts.IsCancellationRequested); @@ -573,6 +576,7 @@ select v.Files[file.TargetFileName].Hashes { Log.Error(ex); BrokenFiles.Add((file.TargetFileName, "Unexpected error: " + ex.Message)); + ValidationStatus = false; } } diff --git a/UI.WinForms.Msil/Forms/MainForm.cs b/UI.WinForms.Msil/Forms/MainForm.cs index 8596e88..8c81d67 100644 --- a/UI.WinForms.Msil/Forms/MainForm.cs +++ b/UI.WinForms.Msil/Forms/MainForm.cs @@ -439,7 +439,10 @@ private void DumpDiscFinished(object sender, RunWorkerCompletedEventArgs e) if (dumper.ValidationStatus == false) { step4StatusLabel.Text = "❌"; - step4Label.Text = "Dump is corrupted"; + if (dumper.BrokenFiles.Count > 0) + step4Label.Text = $"{dumper.BrokenFiles.Count} invalid file{(dumper.BrokenFiles.Count == 1 ? "" : "s")}"; + else + step4Label.Text = "Dump is corrupted"; } else if (dumper.ValidationStatus == true) {