Refactor sector writing methods to include SectorStatus parameter and update related logic

This commit is contained in:
2025-10-22 20:25:23 +01:00
parent 0ac2a48fb6
commit ce0e0dff22
55 changed files with 927 additions and 676 deletions

View File

@@ -118,7 +118,7 @@ partial class Dump
_writeStopwatch.Restart();
byte[] tmpBuf;
byte[] cmi = new byte[blocksToRead];
var cmi = new byte[blocksToRead];
for(uint j = 0; j < blocksToRead; j++)
{
@@ -160,7 +160,10 @@ partial class Dump
buffer = CSS.DecryptSectorLong(buffer, titleKey, cmi, blocksToRead);
}
outputFormat.WriteSectorsLong(buffer, i, blocksToRead);
outputFormat.WriteSectorsLong(buffer,
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true);
@@ -175,7 +178,12 @@ partial class Dump
// Write empty data
_writeStopwatch.Restart();
outputFormat.WriteSectorsLong(new byte[blockSize * _skip], i, _skip);
outputFormat.WriteSectorsLong(new byte[blockSize * _skip],
i,
_skip,
Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b);

View File

@@ -189,7 +189,12 @@ partial class Dump
mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024);
_writeStopwatch.Restart();
outputFormat.WriteSectors(buffer, i, blocksToRead);
outputFormat.WriteSectors(buffer,
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true);
_mediaGraph?.PaintSectorsGood(i, blocksToRead);
@@ -217,7 +222,12 @@ partial class Dump
// Write empty data
_writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip);
outputFormat.WriteSectors(new byte[blockSize * _skip],
i,
_skip,
Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b);

View File

@@ -57,9 +57,9 @@ partial class Dump
void RetrySbcData(Reader scsiReader, DumpHardware currentTry, ExtentsULong extents, ref double totalDuration,
ExtentsULong blankExtents, byte[] discKey)
{
int pass = 1;
bool forward = true;
bool runningPersistent = false;
var pass = 1;
var forward = true;
var runningPersistent = false;
bool sense;
byte[] buffer;
bool recoveredError;
@@ -67,7 +67,7 @@ partial class Dump
byte[] md6;
byte[] md10;
bool blankCheck;
bool newBlank = false;
var newBlank = false;
var outputFormat = _outputPlugin as IWritableImage;
if(_persistent)
@@ -310,7 +310,7 @@ partial class Dump
if(scsiReader.LiteOnReadRaw || scsiReader.HldtstReadRaw)
{
byte[] cmi = new byte[1];
var cmi = new byte[1];
byte[] key = buffer.Skip(7).Take(5).ToArray();
@@ -348,10 +348,10 @@ partial class Dump
}
_resume.BadBlocks.Remove(badSector);
outputFormat.WriteSectorLong(buffer, badSector);
outputFormat.WriteSectorLong(buffer, badSector, SectorStatus.Dumped);
}
else
outputFormat.WriteSector(buffer, badSector);
outputFormat.WriteSector(buffer, badSector, SectorStatus.Dumped);
_mediaGraph?.PaintSectorGood(badSector);
@@ -359,7 +359,7 @@ partial class Dump
badSector,
pass));
}
else if(runningPersistent) outputFormat.WriteSector(buffer, badSector);
else if(runningPersistent) outputFormat.WriteSector(buffer, badSector, SectorStatus.Errored);
}
if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0)
@@ -397,8 +397,8 @@ partial class Dump
void RetryTitleKeys(DVDDecryption dvdDecrypt, byte[] discKey, ref double totalDuration)
{
int pass = 1;
bool forward = true;
var pass = 1;
var forward = true;
bool sense;
byte[] buffer;

View File

@@ -5,6 +5,7 @@
using System;
using System.Linq;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Extents;
using Aaru.CommonTypes.Interfaces;
using Aaru.Core.Logging;
@@ -52,7 +53,7 @@ partial class Dump
bool sense;
byte[] buffer;
ulong sectorSpeedStart = 0;
bool canMediumScan = true;
var canMediumScan = true;
var outputFormat = _outputPlugin as IWritableImage;
InitProgress?.Invoke();
@@ -179,9 +180,8 @@ partial class Dump
writtenExtents.Add(0, blocks - 1);
foreach(Tuple<ulong, ulong> blank in blankExtents.ToArray())
{
for(ulong b = blank.Item1; b <= blank.Item2; b++) writtenExtents.Remove(b);
}
for(ulong b = blank.Item1; b <= blank.Item2; b++)
writtenExtents.Remove(b);
}
if(writtenExtents.Count == 0)
@@ -236,7 +236,12 @@ partial class Dump
mhddLog.Write(i, cmdDuration, blocksToRead);
ibgLog.Write(i, currentSpeed * 1024);
_writeStopwatch.Restart();
outputFormat.WriteSectors(buffer, i, blocksToRead);
outputFormat.WriteSectors(buffer,
i,
blocksToRead,
Enumerable.Repeat(SectorStatus.Dumped, (int)blocksToRead).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
extents.Add(i, blocksToRead, true);
}
@@ -249,7 +254,12 @@ partial class Dump
// Write empty data
_writeStopwatch.Restart();
outputFormat.WriteSectors(new byte[blockSize * _skip], i, _skip);
outputFormat.WriteSectors(new byte[blockSize * _skip],
i,
_skip,
Enumerable.Repeat(SectorStatus.NotDumped, (int)_skip).ToArray());
imageWriteDuration += _writeStopwatch.Elapsed.TotalSeconds;
for(ulong b = i; b < i + _skip; b++) _resume.BadBlocks.Add(b);

View File

@@ -52,7 +52,7 @@ partial class Dump
bool recoveredError;
bool blankCheck;
byte[] buffer;
bool newBlank = false;
var newBlank = false;
if(_outputPlugin is not IWritableImage outputFormat)
{
@@ -101,7 +101,7 @@ partial class Dump
if(scsiReader.LiteOnReadRaw || scsiReader.HldtstReadRaw)
{
byte[] cmi = new byte[1];
var cmi = new byte[1];
byte[] key = buffer.Skip(7).Take(5).ToArray();
@@ -138,10 +138,10 @@ partial class Dump
}
_resume.BadBlocks.Remove(badSector);
outputFormat.WriteSectorLong(buffer, badSector);
outputFormat.WriteSectorLong(buffer, badSector, SectorStatus.Dumped);
}
else
outputFormat.WriteSector(buffer, badSector);
outputFormat.WriteSector(buffer, badSector, SectorStatus.Dumped);
_mediaGraph?.PaintSectorGood(badSector);
}