🐛No retry passes means do not retry errors, act so.

This commit is contained in:
2018-04-09 20:21:42 +01:00
parent 97073e34f0
commit 47e78ba0d4
5 changed files with 127 additions and 140 deletions

View File

@@ -74,16 +74,15 @@ namespace DiscImageChef.Core.Devices.Dumping
/// <param name="outputPath">Path to output file</param> /// <param name="outputPath">Path to output file</param>
/// <param name="formatOptions">Formats to pass to output file plugin</param> /// <param name="formatOptions">Formats to pass to output file plugin</param>
/// <exception cref="InvalidOperationException">If the resume file is invalid</exception> /// <exception cref="InvalidOperationException">If the resume file is invalid</exception>
public static void Dump(Device dev, string devicePath, IWritableImage outputPlugin, ushort retryPasses, public static void Dump(Device dev, string devicePath,
bool force, bool dumpRaw, bool persistent, bool stopOnError, IWritableImage outputPlugin, ushort retryPasses,
ref Resume resume, bool force, bool dumpRaw,
ref bool persistent, bool stopOnError, ref Resume resume,
DumpLog dumpLog, Encoding encoding, string outputPrefix, ref DumpLog dumpLog, Encoding encoding,
string outputPath, string outputPrefix, string outputPath,
Dictionary<string, string> Dictionary<string, string> formatOptions, CICMMetadataType preSidecar,
formatOptions, CICMMetadataType preSidecar, uint skip, uint skip,
bool bool nometadata)
nometadata)
{ {
bool aborted; bool aborted;
@@ -296,17 +295,16 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.WriteLine(); DicConsole.WriteLine();
mhddLog.Close(); mhddLog.Close();
ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
blockSize * blockSize * (double)(blocks + 1) / 1024 /
(double)(blocks + 1) / 1024 / (totalDuration / 1000), devicePath); (totalDuration / 1000), devicePath);
dumpLog.WriteLine("Dump finished in {0} seconds.", dumpLog.WriteLine("Dump finished in {0} seconds.", (end - start).TotalSeconds);
(end - start).TotalSeconds);
dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.", dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.",
(double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000)); (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000));
dumpLog.WriteLine("Average write speed {0:F3} KiB/sec.", dumpLog.WriteLine("Average write speed {0:F3} KiB/sec.",
(double)blockSize * (double)(blocks + 1) / 1024 / imageWriteDuration); (double)blockSize * (double)(blocks + 1) / 1024 / imageWriteDuration);
#region Error handling #region Error handling
if(resume.BadBlocks.Count > 0 && !aborted) if(resume.BadBlocks.Count > 0 && !aborted && retryPasses > 0)
{ {
int pass = 0; int pass = 0;
bool forward = true; bool forward = true;
@@ -337,8 +335,7 @@ namespace DiscImageChef.Core.Devices.Dumping
outputPlugin.WriteSector(cmdBuf, badSector); outputPlugin.WriteSector(cmdBuf, badSector);
dumpLog.WriteLine("Correctly retried block {0} in pass {1}.", badSector, pass); dumpLog.WriteLine("Correctly retried block {0} in pass {1}.", badSector, pass);
} }
else if(persistent) else if(persistent) outputPlugin.WriteSector(cmdBuf, badSector);
outputPlugin.WriteSector(cmdBuf, badSector);
} }
if(pass < retryPasses && !aborted && resume.BadBlocks.Count > 0) if(pass < retryPasses && !aborted && resume.BadBlocks.Count > 0)
@@ -426,10 +423,9 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.WriteLine(); DicConsole.WriteLine();
mhddLog.Close(); mhddLog.Close();
ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
blockSize * blockSize * (double)(blocks + 1) / 1024 /
(double)(blocks + 1) / 1024 / (totalDuration / 1000), devicePath); (totalDuration / 1000), devicePath);
dumpLog.WriteLine("Dump finished in {0} seconds.", dumpLog.WriteLine("Dump finished in {0} seconds.", (end - start).TotalSeconds);
(end - start).TotalSeconds);
dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.", dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.",
(double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000)); (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000));
dumpLog.WriteLine("Average write speed {0:F3} KiB/sec.", dumpLog.WriteLine("Average write speed {0:F3} KiB/sec.",
@@ -630,10 +626,8 @@ namespace DiscImageChef.Core.Devices.Dumping
} }
if(dev.IsCompactFlash) Statistics.AddMedia(MediaType.CompactFlash, true); if(dev.IsCompactFlash) Statistics.AddMedia(MediaType.CompactFlash, true);
else if(dev.IsPcmcia) else if(dev.IsPcmcia) Statistics.AddMedia(MediaType.PCCardTypeI, true);
Statistics.AddMedia(MediaType.PCCardTypeI, true); else Statistics.AddMedia(MediaType.GENERIC_HDD, true);
else
Statistics.AddMedia(MediaType.GENERIC_HDD, true);
} }
else DicConsole.ErrorWriteLine("Unable to communicate with ATA device."); else DicConsole.ErrorWriteLine("Unable to communicate with ATA device.");
} }

View File

@@ -897,7 +897,7 @@ namespace DiscImageChef.Core.Devices.Dumping
#region Compact Disc Error handling #region Compact Disc Error handling
// TODO: Pass 0 should be called differently, splitting, or something like that, because we are just // TODO: Pass 0 should be called differently, splitting, or something like that, because we are just
// separating skipped good sectors from really bad sectors and it's getting too chatty on log there... // separating skipped good sectors from really bad sectors and it's getting too chatty on log there...
if(resume.BadBlocks.Count > 0 && !aborted) if(resume.BadBlocks.Count > 0 && !aborted && retryPasses > 0)
{ {
int pass = 0; int pass = 0;
bool forward = true; bool forward = true;

View File

@@ -418,7 +418,7 @@ namespace DiscImageChef.Core.Devices.Dumping
(double)blockSize * (double)(blocks + 1) / 1024 / imageWriteDuration); (double)blockSize * (double)(blocks + 1) / 1024 / imageWriteDuration);
#region Error handling #region Error handling
if(resume.BadBlocks.Count > 0 && !aborted) if(resume.BadBlocks.Count > 0 && !aborted && retryPasses > 0)
{ {
int pass = 0; int pass = 0;
bool forward = true; bool forward = true;

View File

@@ -72,14 +72,15 @@ namespace DiscImageChef.Core.Devices.Dumping
/// <param name="outputPath">Path to output file</param> /// <param name="outputPath">Path to output file</param>
/// <param name="formatOptions">Formats to pass to output file plugin</param> /// <param name="formatOptions">Formats to pass to output file plugin</param>
/// <exception cref="ArgumentException">If you asked to dump long sectors from a SCSI Streaming device</exception> /// <exception cref="ArgumentException">If you asked to dump long sectors from a SCSI Streaming device</exception>
public static void Dump(Device dev, string devicePath, IWritableImage outputPlugin, ushort retryPasses, public static void Dump(Device dev, string devicePath,
bool force, bool dumpRaw, bool persistent, bool stopOnError, IWritableImage outputPlugin, ushort retryPasses,
ref Resume resume, bool force, bool dumpRaw,
ref bool persistent, bool stopOnError, ref Resume resume,
DumpLog dumpLog, Encoding encoding, string outputPrefix, ref DumpLog dumpLog, Encoding encoding,
string outputPath, string outputPrefix, string outputPath,
Dictionary<string, string> Dictionary<string, string> formatOptions, CICMMetadataType preSidecar,
formatOptions, CICMMetadataType preSidecar, uint skip, bool nometadata) uint skip,
bool nometadata)
{ {
bool aborted; bool aborted;
@@ -125,8 +126,7 @@ namespace DiscImageChef.Core.Devices.Dumping
blocks = ecsdDecoded.SectorCount; blocks = ecsdDecoded.SectorCount;
blockSize = (uint)(ecsdDecoded.SectorSize == 1 ? 4096 : 512); blockSize = (uint)(ecsdDecoded.SectorSize == 1 ? 4096 : 512);
if(ecsdDecoded.NativeSectorSize == 0) physicalBlockSize = 512; if(ecsdDecoded.NativeSectorSize == 0) physicalBlockSize = 512;
else if(ecsdDecoded.NativeSectorSize == 1) else if(ecsdDecoded.NativeSectorSize == 1) physicalBlockSize = 4096;
physicalBlockSize = 4096;
// Supposing it's high-capacity MMC if it has Extended CSD... // Supposing it's high-capacity MMC if it has Extended CSD...
byteAddressed = false; byteAddressed = false;
mediaTags.Add(MediaTagType.MMC_ExtendedCSD, null); mediaTags.Add(MediaTagType.MMC_ExtendedCSD, null);
@@ -140,8 +140,7 @@ namespace DiscImageChef.Core.Devices.Dumping
if(blocks == 0) if(blocks == 0)
{ {
CSD csdDecoded = Decoders.MMC.Decoders.DecodeCSD(csd); CSD csdDecoded = Decoders.MMC.Decoders.DecodeCSD(csd);
blocks = blocks = (ulong)((csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2));
(ulong)((csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2));
blockSize = (uint)Math.Pow(2, csdDecoded.ReadBlockLength); blockSize = (uint)Math.Pow(2, csdDecoded.ReadBlockLength);
} }
@@ -164,8 +163,7 @@ namespace DiscImageChef.Core.Devices.Dumping
{ {
Decoders.SecureDigital.CSD csdDecoded = Decoders.SecureDigital.Decoders.DecodeCSD(csd); Decoders.SecureDigital.CSD csdDecoded = Decoders.SecureDigital.Decoders.DecodeCSD(csd);
blocks = (ulong)(csdDecoded.Structure == 0 blocks = (ulong)(csdDecoded.Structure == 0
? (csdDecoded.Size + 1) * ? (csdDecoded.Size + 1) * Math.Pow(2, csdDecoded.SizeMultiplier + 2)
Math.Pow(2, csdDecoded.SizeMultiplier + 2)
: (csdDecoded.Size + 1) * 1024); : (csdDecoded.Size + 1) * 1024);
blockSize = (uint)Math.Pow(2, csdDecoded.ReadBlockLength); blockSize = (uint)Math.Pow(2, csdDecoded.ReadBlockLength);
// Structure >=1 for SDHC/SDXC, so that's block addressed // Structure >=1 for SDHC/SDXC, so that's block addressed
@@ -265,9 +263,7 @@ namespace DiscImageChef.Core.Devices.Dumping
MhddLog mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, blocksToRead); MhddLog mhddLog = new MhddLog(outputPrefix + ".mhddlog.bin", dev, blocks, blockSize, blocksToRead);
IbgLog ibgLog = new IbgLog(outputPrefix + ".ibg", SD_PROFILE); IbgLog ibgLog = new IbgLog(outputPrefix + ".ibg", SD_PROFILE);
ret = outputPlugin.Create(outputPath, ret = outputPlugin.Create(outputPath,
dev.Type == DeviceType.SecureDigital dev.Type == DeviceType.SecureDigital ? MediaType.SecureDigital : MediaType.MMC,
? MediaType.SecureDigital
: MediaType.MMC,
formatOptions, blocks, blockSize); formatOptions, blocks, blockSize);
// Cannot create image // Cannot create image
@@ -341,17 +337,16 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.WriteLine(); DicConsole.WriteLine();
mhddLog.Close(); mhddLog.Close();
ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
blockSize * (double)(blocks + 1) / blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000),
1024 / (totalDuration / 1000), devicePath); devicePath);
dumpLog.WriteLine("Dump finished in {0} seconds.", dumpLog.WriteLine("Dump finished in {0} seconds.", (end - start).TotalSeconds);
(end - start).TotalSeconds);
dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.", dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.",
(double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000)); (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000));
dumpLog.WriteLine("Average write speed {0:F3} KiB/sec.", dumpLog.WriteLine("Average write speed {0:F3} KiB/sec.",
(double)blockSize * (double)(blocks + 1) / 1024 / imageWriteDuration); (double)blockSize * (double)(blocks + 1) / 1024 / imageWriteDuration);
#region Error handling #region Error handling
if(resume.BadBlocks.Count > 0 && !aborted) if(resume.BadBlocks.Count > 0 && !aborted && retryPasses > 0)
{ {
int pass = 0; int pass = 0;
bool forward = true; bool forward = true;
@@ -384,8 +379,7 @@ namespace DiscImageChef.Core.Devices.Dumping
outputPlugin.WriteSector(cmdBuf, badSector); outputPlugin.WriteSector(cmdBuf, badSector);
dumpLog.WriteLine("Correctly retried block {0} in pass {1}.", badSector, pass); dumpLog.WriteLine("Correctly retried block {0} in pass {1}.", badSector, pass);
} }
else if(runningPersistent) else if(runningPersistent) outputPlugin.WriteSector(cmdBuf, badSector);
outputPlugin.WriteSector(cmdBuf, badSector);
} }
if(pass < retryPasses && !aborted && resume.BadBlocks.Count > 0) if(pass < retryPasses && !aborted && resume.BadBlocks.Count > 0)

View File

@@ -86,10 +86,11 @@ namespace DiscImageChef.Core.Devices.Dumping
bool persistent, bool stopOnError, bool persistent, bool stopOnError,
Dictionary<MediaTagType, byte[]> mediaTags, ref MediaType dskType, Dictionary<MediaTagType, byte[]> mediaTags, ref MediaType dskType,
ref Resume resume, ref Resume resume,
ref DumpLog dumpLog, ref DumpLog dumpLog, Encoding encoding,
Encoding encoding, string outputPrefix, string outputPath, string outputPrefix, string outputPath,
Dictionary<string, string> formatOptions, Dictionary<string, string> formatOptions, CICMMetadataType preSidecar,
CICMMetadataType preSidecar, uint skip, bool nometadata) uint skip,
bool nometadata)
{ {
bool sense; bool sense;
ulong blocks; ulong blocks;
@@ -640,17 +641,16 @@ namespace DiscImageChef.Core.Devices.Dumping
DicConsole.WriteLine(); DicConsole.WriteLine();
mhddLog.Close(); mhddLog.Close();
ibgLog.Close(dev, blocks, BLOCK_SIZE, (end - start).TotalSeconds, currentSpeed * 1024, ibgLog.Close(dev, blocks, BLOCK_SIZE, (end - start).TotalSeconds, currentSpeed * 1024,
BLOCK_SIZE * (double)(blocks + 1) / BLOCK_SIZE * (double)(blocks + 1) / 1024 / (totalDuration / 1000),
1024 / (totalDuration / 1000), devicePath); devicePath);
dumpLog.WriteLine("Dump finished in {0} seconds.", dumpLog.WriteLine("Dump finished in {0} seconds.", (end - start).TotalSeconds);
(end - start).TotalSeconds);
dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.", dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.",
(double)BLOCK_SIZE * (double)(blocks + 1) / 1024 / (totalDuration / 1000)); (double)BLOCK_SIZE * (double)(blocks + 1) / 1024 / (totalDuration / 1000));
dumpLog.WriteLine("Average write speed {0:F3} KiB/sec.", dumpLog.WriteLine("Average write speed {0:F3} KiB/sec.",
(double)BLOCK_SIZE * (double)(blocks + 1) / 1024 / imageWriteDuration); (double)BLOCK_SIZE * (double)(blocks + 1) / 1024 / imageWriteDuration);
#region Error handling #region Error handling
if(resume.BadBlocks.Count > 0 && !aborted) if(resume.BadBlocks.Count > 0 && !aborted && retryPasses > 0)
{ {
List<ulong> tmpList = new List<ulong>(); List<ulong> tmpList = new List<ulong>();
@@ -692,8 +692,7 @@ namespace DiscImageChef.Core.Devices.Dumping
outputPlugin.WriteSector(readBuffer, badSector); outputPlugin.WriteSector(readBuffer, badSector);
dumpLog.WriteLine("Correctly retried block {0} in pass {1}.", badSector, pass); dumpLog.WriteLine("Correctly retried block {0} in pass {1}.", badSector, pass);
} }
else if(runningPersistent) else if(runningPersistent) outputPlugin.WriteSector(readBuffer, badSector);
outputPlugin.WriteSector(readBuffer, badSector);
} }
if(pass < retryPasses && !aborted && resume.BadBlocks.Count > 0) if(pass < retryPasses && !aborted && resume.BadBlocks.Count > 0)