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.");
|
||||
|
||||
@@ -69,22 +69,20 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
/// <param name="dskType">Disc type as detected in MMC layer</param>
|
||||
internal void CompactDisc(ref MediaType dskType)
|
||||
{
|
||||
uint subSize;
|
||||
DateTime start;
|
||||
DateTime end;
|
||||
bool readcd;
|
||||
bool read6 = false, read10 = false, read12 = false, read16 = false;
|
||||
bool sense = false;
|
||||
const uint SECTOR_SIZE = 2352;
|
||||
FullTOC.CDFullTOC? toc = null;
|
||||
double totalDuration = 0;
|
||||
double currentSpeed = 0;
|
||||
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[]>();
|
||||
uint subSize;
|
||||
DateTime start;
|
||||
DateTime end;
|
||||
bool readcd;
|
||||
bool read6 = false, read10 = false, read12 = false, read16 = false;
|
||||
bool sense = false;
|
||||
const uint SECTOR_SIZE = 2352;
|
||||
FullTOC.CDFullTOC? toc = null;
|
||||
double totalDuration = 0;
|
||||
double currentSpeed = 0;
|
||||
double maxSpeed = double.MinValue;
|
||||
double minSpeed = double.MaxValue;
|
||||
uint blocksToRead = 64;
|
||||
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,13 +665,11 @@ 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;
|
||||
bool sense;
|
||||
DateTime start;
|
||||
DateTime end;
|
||||
MediaType dskType;
|
||||
bool sense;
|
||||
|
||||
sense = dev.ReadCapacity(out byte[] readBuffer, out _, dev.Timeout, out _);
|
||||
|
||||
|
||||
@@ -64,20 +64,18 @@ namespace DiscImageChef.Core.Devices.Dumping
|
||||
/// <param name="dskType">Disc type as detected in SCSI or MMC layer</param>
|
||||
internal void Sbc(Dictionary<MediaTagType, byte[]> mediaTags, ref MediaType dskType, bool opticalDisc)
|
||||
{
|
||||
bool sense;
|
||||
byte scsiMediumType = 0;
|
||||
byte scsiDensityCode = 0;
|
||||
bool containsFloppyPage = false;
|
||||
const ushort SBC_PROFILE = 0x0001;
|
||||
DateTime start;
|
||||
DateTime end;
|
||||
double totalDuration = 0;
|
||||
double currentSpeed = 0;
|
||||
double maxSpeed = double.MinValue;
|
||||
double minSpeed = double.MaxValue;
|
||||
byte[] readBuffer;
|
||||
bool aborted = false;
|
||||
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
|
||||
bool sense;
|
||||
byte scsiMediumType = 0;
|
||||
byte scsiDensityCode = 0;
|
||||
bool containsFloppyPage = false;
|
||||
const ushort SBC_PROFILE = 0x0001;
|
||||
DateTime start;
|
||||
DateTime end;
|
||||
double totalDuration = 0;
|
||||
double currentSpeed = 0;
|
||||
double maxSpeed = double.MinValue;
|
||||
double minSpeed = double.MaxValue;
|
||||
byte[] readBuffer;
|
||||
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);
|
||||
|
||||
@@ -57,7 +57,9 @@ namespace DiscImageChef.Gui.Forms
|
||||
{
|
||||
public class frmDump : Form
|
||||
{
|
||||
readonly string devicePath;
|
||||
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,13 +453,12 @@ namespace DiscImageChef.Gui.Forms
|
||||
parsedOptions.Add(key, value);
|
||||
}
|
||||
|
||||
Dump 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,
|
||||
chkExistingMetadata.Checked == false, chkTrim.Checked == false,
|
||||
chkTrack1Pregap.Checked == true);
|
||||
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,
|
||||
chkExistingMetadata.Checked == false, chkTrim.Checked == false,
|
||||
chkTrack1Pregap.Checked == true);
|
||||
|
||||
/*dumper.UpdateStatus += Progress.UpdateStatus;
|
||||
dumper.ErrorMessage += Progress.ErrorMessage;
|
||||
|
||||
@@ -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