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>
|
/// </summary>
|
||||||
public void Ata()
|
public void Ata()
|
||||||
{
|
{
|
||||||
bool aborted;
|
|
||||||
|
|
||||||
if(dumpRaw)
|
if(dumpRaw)
|
||||||
{
|
{
|
||||||
if(force) ErrorMessage?.Invoke("Raw dumping not yet supported in ATA devices, continuing...");
|
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 maxSpeed = double.MinValue;
|
||||||
double minSpeed = double.MaxValue;
|
double minSpeed = double.MaxValue;
|
||||||
|
|
||||||
aborted = false;
|
|
||||||
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
|
|
||||||
|
|
||||||
// Initializate reader
|
// Initializate reader
|
||||||
UpdateStatus?.Invoke("Initializing reader.");
|
UpdateStatus?.Invoke("Initializing reader.");
|
||||||
dumpLog.WriteLine("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>
|
/// <param name="dskType">Disc type as detected in MMC layer</param>
|
||||||
internal void CompactDisc(ref MediaType dskType)
|
internal void CompactDisc(ref MediaType dskType)
|
||||||
{
|
{
|
||||||
uint subSize;
|
uint subSize;
|
||||||
DateTime start;
|
DateTime start;
|
||||||
DateTime end;
|
DateTime end;
|
||||||
bool readcd;
|
bool readcd;
|
||||||
bool read6 = false, read10 = false, read12 = false, read16 = false;
|
bool read6 = false, read10 = false, read12 = false, read16 = false;
|
||||||
bool sense = false;
|
bool sense = false;
|
||||||
const uint SECTOR_SIZE = 2352;
|
const uint SECTOR_SIZE = 2352;
|
||||||
FullTOC.CDFullTOC? toc = null;
|
FullTOC.CDFullTOC? toc = null;
|
||||||
double totalDuration = 0;
|
double totalDuration = 0;
|
||||||
double currentSpeed = 0;
|
double currentSpeed = 0;
|
||||||
double maxSpeed = double.MinValue;
|
double maxSpeed = double.MinValue;
|
||||||
double minSpeed = double.MaxValue;
|
double minSpeed = double.MaxValue;
|
||||||
uint blocksToRead = 64;
|
uint blocksToRead = 64;
|
||||||
bool aborted = false;
|
Dictionary<MediaTagType, byte[]> mediaTags = new Dictionary<MediaTagType, byte[]>();
|
||||||
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
|
|
||||||
Dictionary<MediaTagType, byte[]> mediaTags = new Dictionary<MediaTagType, byte[]>();
|
|
||||||
|
|
||||||
if(dumpRaw)
|
if(dumpRaw)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ namespace DiscImageChef.Core.Devices.Dumping
|
|||||||
readonly CICMMetadataType preSidecar;
|
readonly CICMMetadataType preSidecar;
|
||||||
readonly ushort retryPasses;
|
readonly ushort retryPasses;
|
||||||
readonly bool stopOnError;
|
readonly bool stopOnError;
|
||||||
|
bool aborted;
|
||||||
bool dumpFirstTrackPregap;
|
bool dumpFirstTrackPregap;
|
||||||
Resume resume;
|
Resume resume;
|
||||||
uint skip;
|
uint skip;
|
||||||
@@ -87,6 +88,7 @@ namespace DiscImageChef.Core.Devices.Dumping
|
|||||||
this.nometadata = nometadata;
|
this.nometadata = nometadata;
|
||||||
this.notrim = notrim;
|
this.notrim = notrim;
|
||||||
this.dumpFirstTrackPregap = dumpFirstTrackPregap;
|
this.dumpFirstTrackPregap = dumpFirstTrackPregap;
|
||||||
|
aborted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -136,6 +138,11 @@ namespace DiscImageChef.Core.Devices.Dumping
|
|||||||
fs.Close();
|
fs.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Abort()
|
||||||
|
{
|
||||||
|
aborted = true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event raised when the progress bar is not longer needed
|
/// Event raised when the progress bar is not longer needed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -180,10 +180,8 @@ namespace DiscImageChef.Core.Devices.Dumping
|
|||||||
double currentSpeed = 0;
|
double currentSpeed = 0;
|
||||||
double maxSpeed = double.MinValue;
|
double maxSpeed = double.MinValue;
|
||||||
double minSpeed = double.MaxValue;
|
double minSpeed = double.MaxValue;
|
||||||
bool aborted = false;
|
|
||||||
DateTime start;
|
DateTime start;
|
||||||
DateTime end;
|
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,
|
bool sense = dev.Read12(out byte[] readBuffer, out _, 0, false, true, false, false, 0, 512, 0, 1, false,
|
||||||
dev.Timeout, out _);
|
dev.Timeout, out _);
|
||||||
@@ -667,13 +665,11 @@ namespace DiscImageChef.Core.Devices.Dumping
|
|||||||
double currentSpeed = 0;
|
double currentSpeed = 0;
|
||||||
double maxSpeed = double.MinValue;
|
double maxSpeed = double.MinValue;
|
||||||
double minSpeed = double.MaxValue;
|
double minSpeed = double.MaxValue;
|
||||||
bool aborted = false;
|
|
||||||
uint blocksToRead = 64;
|
uint blocksToRead = 64;
|
||||||
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
|
DateTime start;
|
||||||
DateTime start;
|
DateTime end;
|
||||||
DateTime end;
|
MediaType dskType;
|
||||||
MediaType dskType;
|
bool sense;
|
||||||
bool sense;
|
|
||||||
|
|
||||||
sense = dev.ReadCapacity(out byte[] readBuffer, out _, dev.Timeout, out _);
|
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>
|
/// <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)
|
internal void Sbc(Dictionary<MediaTagType, byte[]> mediaTags, ref MediaType dskType, bool opticalDisc)
|
||||||
{
|
{
|
||||||
bool sense;
|
bool sense;
|
||||||
byte scsiMediumType = 0;
|
byte scsiMediumType = 0;
|
||||||
byte scsiDensityCode = 0;
|
byte scsiDensityCode = 0;
|
||||||
bool containsFloppyPage = false;
|
bool containsFloppyPage = false;
|
||||||
const ushort SBC_PROFILE = 0x0001;
|
const ushort SBC_PROFILE = 0x0001;
|
||||||
DateTime start;
|
DateTime start;
|
||||||
DateTime end;
|
DateTime end;
|
||||||
double totalDuration = 0;
|
double totalDuration = 0;
|
||||||
double currentSpeed = 0;
|
double currentSpeed = 0;
|
||||||
double maxSpeed = double.MinValue;
|
double maxSpeed = double.MinValue;
|
||||||
double minSpeed = double.MaxValue;
|
double minSpeed = double.MaxValue;
|
||||||
byte[] readBuffer;
|
byte[] readBuffer;
|
||||||
bool aborted = false;
|
|
||||||
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
|
|
||||||
Modes.DecodedMode? decMode = null;
|
Modes.DecodedMode? decMode = null;
|
||||||
|
|
||||||
dumpLog.WriteLine("Initializing reader.");
|
dumpLog.WriteLine("Initializing reader.");
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ namespace DiscImageChef.Core.Devices.Dumping
|
|||||||
internal void Ssc()
|
internal void Ssc()
|
||||||
{
|
{
|
||||||
FixedSense? fxSense;
|
FixedSense? fxSense;
|
||||||
bool aborted;
|
|
||||||
bool sense;
|
bool sense;
|
||||||
ulong blocks = 0;
|
ulong blocks = 0;
|
||||||
uint blockSize;
|
uint blockSize;
|
||||||
@@ -403,8 +402,6 @@ namespace DiscImageChef.Core.Devices.Dumping
|
|||||||
};
|
};
|
||||||
Checksum partitionChk = new Checksum();
|
Checksum partitionChk = new Checksum();
|
||||||
|
|
||||||
aborted = false;
|
|
||||||
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
|
|
||||||
DateTime timeSpeedStart = DateTime.UtcNow;
|
DateTime timeSpeedStart = DateTime.UtcNow;
|
||||||
ulong currentSpeedSize = 0;
|
ulong currentSpeedSize = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -57,8 +57,6 @@ namespace DiscImageChef.Core.Devices.Dumping
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void SecureDigital()
|
public void SecureDigital()
|
||||||
{
|
{
|
||||||
bool aborted;
|
|
||||||
|
|
||||||
if(dumpRaw)
|
if(dumpRaw)
|
||||||
{
|
{
|
||||||
if(force)
|
if(force)
|
||||||
@@ -182,9 +180,6 @@ namespace DiscImageChef.Core.Devices.Dumping
|
|||||||
double maxSpeed = double.MinValue;
|
double maxSpeed = double.MinValue;
|
||||||
double minSpeed = double.MaxValue;
|
double minSpeed = double.MaxValue;
|
||||||
|
|
||||||
aborted = false;
|
|
||||||
System.Console.CancelKeyPress += (sender, e) => e.Cancel = aborted = true;
|
|
||||||
|
|
||||||
if(blocks == 0)
|
if(blocks == 0)
|
||||||
{
|
{
|
||||||
dumpLog.WriteLine("Unable to get device size.");
|
dumpLog.WriteLine("Unable to get device size.");
|
||||||
|
|||||||
@@ -74,8 +74,6 @@ namespace DiscImageChef.Core.Devices.Dumping
|
|||||||
double currentSpeed = 0;
|
double currentSpeed = 0;
|
||||||
double maxSpeed = double.MinValue;
|
double maxSpeed = double.MinValue;
|
||||||
double minSpeed = double.MaxValue;
|
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_PFI)) mediaTags.Remove(MediaTagType.DVD_PFI);
|
||||||
if(mediaTags.ContainsKey(MediaTagType.DVD_DMI)) mediaTags.Remove(MediaTagType.DVD_DMI);
|
if(mediaTags.ContainsKey(MediaTagType.DVD_DMI)) mediaTags.Remove(MediaTagType.DVD_DMI);
|
||||||
|
|||||||
@@ -57,7 +57,9 @@ namespace DiscImageChef.Gui.Forms
|
|||||||
{
|
{
|
||||||
public class frmDump : Form
|
public class frmDump : Form
|
||||||
{
|
{
|
||||||
readonly string devicePath;
|
readonly string devicePath;
|
||||||
|
|
||||||
|
Dump dumper;
|
||||||
string outputPrefix;
|
string outputPrefix;
|
||||||
Resume resume;
|
Resume resume;
|
||||||
CICMMetadataType sidecar;
|
CICMMetadataType sidecar;
|
||||||
@@ -378,6 +380,11 @@ namespace DiscImageChef.Gui.Forms
|
|||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnBtnAbortClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
dumper.Abort();
|
||||||
|
}
|
||||||
|
|
||||||
void OnBtnDumpClick(object sender, EventArgs e)
|
void OnBtnDumpClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Device dev;
|
Device dev;
|
||||||
@@ -446,13 +453,12 @@ namespace DiscImageChef.Gui.Forms
|
|||||||
parsedOptions.Add(key, value);
|
parsedOptions.Add(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dump dumper = new Dump(chkResume.Checked == true, dev, devicePath, outputFormat,
|
dumper = new Dump(chkResume.Checked == true, dev, devicePath, outputFormat, (ushort)stpRetries.Value,
|
||||||
(ushort)stpRetries.Value,
|
chkForce.Checked == true, false, chkPersistent.Checked == true,
|
||||||
chkForce.Checked == true, false, chkPersistent.Checked == true,
|
chkStopOnError.Checked == true, resume, dumpLog, encoding, outputPrefix,
|
||||||
chkStopOnError.Checked == true, resume, dumpLog, encoding, outputPrefix,
|
txtDestination.Text, parsedOptions, sidecar, (uint)stpSkipped.Value,
|
||||||
txtDestination.Text, parsedOptions, sidecar, (uint)stpSkipped.Value,
|
chkExistingMetadata.Checked == false, chkTrim.Checked == false,
|
||||||
chkExistingMetadata.Checked == false, chkTrim.Checked == false,
|
chkTrack1Pregap.Checked == true);
|
||||||
chkTrack1Pregap.Checked == true);
|
|
||||||
|
|
||||||
/*dumper.UpdateStatus += Progress.UpdateStatus;
|
/*dumper.UpdateStatus += Progress.UpdateStatus;
|
||||||
dumper.ErrorMessage += Progress.ErrorMessage;
|
dumper.ErrorMessage += Progress.ErrorMessage;
|
||||||
|
|||||||
@@ -304,6 +304,11 @@ namespace DiscImageChef.Commands
|
|||||||
dumper.PulseProgress += Progress.PulseProgress;
|
dumper.PulseProgress += Progress.PulseProgress;
|
||||||
dumper.InitProgress += Progress.InitProgress;
|
dumper.InitProgress += Progress.InitProgress;
|
||||||
dumper.EndProgress += Progress.EndProgress;
|
dumper.EndProgress += Progress.EndProgress;
|
||||||
|
System.Console.CancelKeyPress += (sender, e) =>
|
||||||
|
{
|
||||||
|
e.Cancel = true;
|
||||||
|
dumper.Abort();
|
||||||
|
};
|
||||||
|
|
||||||
dumper.Start();
|
dumper.Start();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user