Skip to content

Commit

Permalink
in case of disc read errors mark dump as broken
Browse files Browse the repository at this point in the history
  • Loading branch information
13xforever committed May 28, 2022
1 parent ee2766f commit 7e39b06
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Ps3DiscDumper/Decrypter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion Ps3DiscDumper/Dumper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<char> InvalidChars = new(Path.GetInvalidFileNameChars().Concat(Path.GetInvalidPathChars()));
private static readonly char[] MultilineSplit = {'\r', '\n'};
Expand Down Expand Up @@ -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"];
Expand Down Expand Up @@ -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);

Expand All @@ -573,6 +576,7 @@ select v.Files[file.TargetFileName].Hashes
{
Log.Error(ex);
BrokenFiles.Add((file.TargetFileName, "Unexpected error: " + ex.Message));
ValidationStatus = false;
}
}

Expand Down
5 changes: 4 additions & 1 deletion UI.WinForms.Msil/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 7e39b06

Please sign in to comment.