mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Centralize abort for dumpers
This commit is contained in:
@@ -57,8 +57,6 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
/// </summary>
|
||||
public void Ata()
|
||||
{
|
||||
bool aborted;
|
||||
|
||||
if(dumpRaw)
|
||||
{
|
||||
if(force) ErrorMessage?.Invoke("Raw dumping not yet supported in ATA devices, continuing...");
|
||||
@@ -92,9 +90,6 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
double maxSpeed = double.MinValue;
|
||||
double minSpeed = double.MaxValue;
|
||||
|
||||
aborted = false;
|
||||
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
|
||||
|
||||
// Initializate reader
|
||||
UpdateStatus?.Invoke("Initializing reader.");
|
||||
dumpLog.WriteLine("Initializing reader.");
|
||||
|
||||
@@ -82,8 +82,6 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
double maxSpeed = double.MinValue;
|
||||
double minSpeed = double.MaxValue;
|
||||
uint blocksToRead = 64;
|
||||
bool aborted = false;
|
||||
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
|
||||
Dictionary<MediaTagType, byte[]> mediaTags = new Dictionary<MediaTagType, byte[]>();
|
||||
|
||||
if(dumpRaw)
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
readonly CICMMetadataType preSidecar;
|
||||
readonly ushort retryPasses;
|
||||
readonly bool stopOnError;
|
||||
bool aborted;
|
||||
bool dumpFirstTrackPregap;
|
||||
Resume resume;
|
||||
uint skip;
|
||||
@@ -87,6 +88,7 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
this.nometadata = nometadata;
|
||||
this.notrim = notrim;
|
||||
this.dumpFirstTrackPregap = dumpFirstTrackPregap;
|
||||
aborted = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -136,6 +138,11 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
fs.Close();
|
||||
}
|
||||
|
||||
public void Abort()
|
||||
{
|
||||
aborted = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event raised when the progress bar is not longer needed
|
||||
/// </summary>
|
||||
|
||||
@@ -180,10 +180,8 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
double currentSpeed = 0;
|
||||
double maxSpeed = double.MinValue;
|
||||
double minSpeed = double.MaxValue;
|
||||
bool aborted = false;
|
||||
DateTime start;
|
||||
DateTime end;
|
||||
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
|
||||
|
||||
bool sense = dev.Read12(out byte[] readBuffer, out _, 0, false, true, false, false, 0, 512, 0, 1, false,
|
||||
dev.Timeout, out _);
|
||||
@@ -667,9 +665,7 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
double currentSpeed = 0;
|
||||
double maxSpeed = double.MinValue;
|
||||
double minSpeed = double.MaxValue;
|
||||
bool aborted = false;
|
||||
uint blocksToRead = 64;
|
||||
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
|
||||
DateTime start;
|
||||
DateTime end;
|
||||
MediaType dskType;
|
||||
|
||||
@@ -76,8 +76,6 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
double maxSpeed = double.MinValue;
|
||||
double minSpeed = double.MaxValue;
|
||||
byte[] readBuffer;
|
||||
bool aborted = false;
|
||||
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
|
||||
Modes.DecodedMode? decMode = null;
|
||||
|
||||
dumpLog.WriteLine("Initializing reader.");
|
||||
|
||||
@@ -55,7 +55,6 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
internal void Ssc()
|
||||
{
|
||||
FixedSense? fxSense;
|
||||
bool aborted;
|
||||
bool sense;
|
||||
ulong blocks = 0;
|
||||
uint blockSize;
|
||||
@@ -403,8 +402,6 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
};
|
||||
Checksum partitionChk = new Checksum();
|
||||
|
||||
aborted = false;
|
||||
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
|
||||
DateTime timeSpeedStart = DateTime.UtcNow;
|
||||
ulong currentSpeedSize = 0;
|
||||
|
||||
|
||||
@@ -57,8 +57,6 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
/// </summary>
|
||||
public void SecureDigital()
|
||||
{
|
||||
bool aborted;
|
||||
|
||||
if(dumpRaw)
|
||||
{
|
||||
if(force)
|
||||
@@ -182,9 +180,6 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
double maxSpeed = double.MinValue;
|
||||
double minSpeed = double.MaxValue;
|
||||
|
||||
aborted = false;
|
||||
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
|
||||
|
||||
if(blocks == 0)
|
||||
{
|
||||
dumpLog.WriteLine("Unable to get device size.");
|
||||
|
||||
@@ -74,8 +74,6 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
double currentSpeed = 0;
|
||||
double maxSpeed = double.MinValue;
|
||||
double minSpeed = double.MaxValue;
|
||||
bool aborted = false;
|
||||
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
|
||||
|
||||
if(mediaTags.ContainsKey(MediaTagType.DVD_PFI)) mediaTags.Remove(MediaTagType.DVD_PFI);
|
||||
if(mediaTags.ContainsKey(MediaTagType.DVD_DMI)) mediaTags.Remove(MediaTagType.DVD_DMI);
|
||||
|
||||
@@ -58,6 +58,8 @@ namespace DiscImageChef.Gui.Forms
|
||||
public class frmDump : Form
|
||||
{
|
||||
readonly string devicePath;
|
||||
|
||||
Dump dumper;
|
||||
string outputPrefix;
|
||||
Resume resume;
|
||||
CICMMetadataType sidecar;
|
||||
@@ -378,6 +380,11 @@ namespace DiscImageChef.Gui.Forms
|
||||
Close();
|
||||
}
|
||||
|
||||
void OnBtnAbortClick(object sender, EventArgs e)
|
||||
{
|
||||
dumper.Abort();
|
||||
}
|
||||
|
||||
void OnBtnDumpClick(object sender, EventArgs e)
|
||||
{
|
||||
Device dev;
|
||||
@@ -446,8 +453,7 @@ namespace DiscImageChef.Gui.Forms
|
||||
parsedOptions.Add(key, value);
|
||||
}
|
||||
|
||||
Dump dumper = new Dump(chkResume.Checked == true, dev, devicePath, outputFormat,
|
||||
(ushort)stpRetries.Value,
|
||||
dumper = new Dump(chkResume.Checked == true, dev, devicePath, outputFormat, (ushort)stpRetries.Value,
|
||||
chkForce.Checked == true, false, chkPersistent.Checked == true,
|
||||
chkStopOnError.Checked == true, resume, dumpLog, encoding, outputPrefix,
|
||||
txtDestination.Text, parsedOptions, sidecar, (uint)stpSkipped.Value,
|
||||
|
||||
@@ -304,6 +304,11 @@ namespace DiscImageChef.Commands
|
||||
dumper.PulseProgress += Progress.PulseProgress;
|
||||
dumper.InitProgress += Progress.InitProgress;
|
||||
dumper.EndProgress += Progress.EndProgress;
|
||||
System.Console.CancelKeyPress += (sender, e) =>
|
||||
{
|
||||
e.Cancel = true;
|
||||
dumper.Abort();
|
||||
};
|
||||
|
||||
dumper.Start();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user