Add option to start retrying errors in reverse.

This commit is contained in:
2026-04-11 10:34:58 +01:00
parent fe8da6033b
commit 4d6f280356
8 changed files with 64 additions and 13 deletions

View File

@@ -213,10 +213,23 @@ partial class Dump
}
InitProgress?.Invoke();
var firstTry = true;
cdRepeatRetry:
ulong[] tmpArray = _resume.BadBlocks.ToArray();
List<ulong> sectorsNotEvenPartial = [];
if(firstTry)
{
if(_startReverse)
{
tmpArray = tmpArray.Reverse().ToArray();
forward = false;
}
firstTry = false;
}
for(var i = 0; i < tmpArray.Length; i++)
{
ulong badSector = tmpArray[i];
@@ -465,9 +478,8 @@ partial class Dump
// MEDIUM ERROR, retry with ignore error below
if(decSense is { ASC: 0x11 })
{
if(!sectorsNotEvenPartial.Contains(badSector)) sectorsNotEvenPartial.Add(badSector);
}
if(!sectorsNotEvenPartial.Contains(badSector))
sectorsNotEvenPartial.Add(badSector);
}
// Because one block has been partially used to fix the offset

View File

@@ -71,6 +71,7 @@ public partial class Dump
const string PREGAP_MODULE_NAME = "Pregap calculator";
const string MODULE_NAME = "Media dumping";
static readonly TimeSpan _oneSecond = 1.Seconds();
readonly bool _bypassWiiDecryption;
readonly bool _createGraph;
readonly bool _cureParanoia;
readonly bool _debug;
@@ -104,7 +105,6 @@ public partial class Dump
readonly Stopwatch _speedStopwatch;
readonly bool _stopOnError;
readonly bool _storeEncrypted;
readonly bool _bypassWiiDecryption;
readonly DumpSubchannel _subchannel;
readonly bool _titleKeys;
readonly bool _trim;
@@ -115,16 +115,17 @@ public partial class Dump
Database.Models.Device _dbDev; // Device database entry
bool _dumpFirstTrackPregap;
bool _fixOffset;
HashSet<ulong> _missingTitleKeysLookup;
bool _missingTitleKeysDirty;
uint _maximumReadable; // Maximum number of sectors drive can read at once
IMediaGraph _mediaGraph;
bool _missingTitleKeysDirty;
HashSet<ulong> _missingTitleKeysLookup;
Resume _resume;
Sidecar _sidecarClass;
uint _skip;
bool _skipCdireadyHole;
int _speed;
int _speedMultiplier;
readonly bool _startReverse;
bool _supportsPlextorD8;
bool _useBufferedReads;
@@ -173,6 +174,7 @@ public partial class Dump
/// <param name="paranoia">Check sectors integrity before writing to image</param>
/// <param name="cureParanoia">Try to fix sectors integrity</param>
/// <param name="bypassWiiDecryption">When dumping Wii (WOD), skip partition AES decryption and store encrypted data</param>
/// <param name="startReverse">Start error retrying in reverse</param>
public Dump(bool doResume, Device dev, string devicePath, IBaseWritableImage outputPlugin, ushort retryPasses,
bool force, bool dumpRaw, bool persistent, bool stopOnError, Resume resume, Encoding encoding,
string outputPrefix, string outputPath, Dictionary<string, string> formatOptions, Metadata preSidecar,
@@ -181,7 +183,7 @@ public partial class Dump
bool fixSubchannel, bool fixSubchannelCrc, bool skipCdireadyHole, ErrorLog errorLog,
bool generateSubchannels, uint maximumReadable, bool useBufferedReads, bool storeEncrypted,
bool titleKeys, uint ignoreCdrRunOuts, bool createGraph, uint dimensions, bool paranoia,
bool cureParanoia, bool bypassWiiDecryption)
bool cureParanoia, bool bypassWiiDecryption, bool startReverse)
{
_doResume = doResume;
_dev = dev;
@@ -226,6 +228,7 @@ public partial class Dump
_paranoia = paranoia;
_cureParanoia = cureParanoia;
_bypassWiiDecryption = bypassWiiDecryption;
_startReverse = startReverse;
_dumpStopwatch = new Stopwatch();
_sidecarStopwatch = new Stopwatch();
_speedStopwatch = new Stopwatch();

View File

@@ -238,9 +238,22 @@ partial class Dump
}
InitProgress?.Invoke();
var firstTry = true;
repeatRetry:
ulong[] tmpArray = _resume.BadBlocks.ToArray();
if(firstTry)
{
if(_startReverse)
{
tmpArray = tmpArray.Reverse().ToArray();
forward = false;
}
firstTry = false;
}
foreach(ulong badSector in tmpArray)
{
if(_aborted)
@@ -308,7 +321,8 @@ partial class Dump
if(outputFormat is null)
{
ErrorMessage?.Invoke(string.Format(Localization.Core.Cannot_write_retried_sector_0_no_writable_output_image,
ErrorMessage?.Invoke(string.Format(Localization.Core
.Cannot_write_retried_sector_0_no_writable_output_image,
badSector));
continue;
@@ -331,7 +345,10 @@ partial class Dump
if(key.All(static k => k == 0))
{
outputFormat.WriteSectorTag(new byte[5], badSector, false, SectorTagType.DvdTitleKeyDecrypted);
outputFormat.WriteSectorTag(new byte[5],
badSector,
false,
SectorTagType.DvdTitleKeyDecrypted);
MarkTitleKeyDumped(badSector);
}
@@ -356,7 +373,7 @@ partial class Dump
if(errno != ErrorNumber.NoError)
{
ErrorMessage?.Invoke(string.Format(Localization.Core
.Error_retrieving_title_key_for_sector_0,
.Error_retrieving_title_key_for_sector_0,
badSector));
}
else
@@ -380,7 +397,8 @@ partial class Dump
{
if(outputFormat is null)
{
ErrorMessage?.Invoke(string.Format(Localization.Core.Cannot_write_retried_sector_0_no_writable_output_image,
ErrorMessage?.Invoke(string.Format(Localization.Core
.Cannot_write_retried_sector_0_no_writable_output_image,
badSector));
continue;

View File

@@ -761,7 +761,8 @@ public sealed partial class MediaDumpViewModel : ViewModelBase
1080,
Paranoia,
CureParanoia,
BypassWiiDecryption);
BypassWiiDecryption,
false);
new Thread(DoWork).Start();
}

View File

@@ -11225,5 +11225,11 @@ namespace Aaru.Localization {
return ResourceManager.GetString("No_files_in_0_overlap_the_affected_sectors", resourceCulture);
}
}
public static string Start_reverse_error_retry {
get {
return ResourceManager.GetString("Start_reverse_error_retry", resourceCulture);
}
}
}
}

View File

@@ -5608,4 +5608,7 @@ Probadores:
<data name="No_files_in_0_overlap_the_affected_sectors" xml:space="preserve">
<value>Ningún archivo en {0} se superpone con los sectores afectados.</value>
</data>
<data name="Start_reverse_error_retry" xml:space="preserve">
<value>Comenzar reintentos de errores al revés.</value>
</data>
</root>

View File

@@ -5692,4 +5692,7 @@ Do you want to continue?</value>
<data name="No_files_in_0_overlap_the_affected_sectors" xml:space="preserve">
<value>No files in {0} overlap the affected sectors.</value>
</data>
<data name="Start_reverse_error_retry" xml:space="preserve">
<value>Start error retrying in reverse.</value>
</data>
</root>

View File

@@ -125,6 +125,7 @@ sealed class DumpMediaCommand : Command<DumpMediaCommand.Settings>
AaruLogging.Debug(MODULE_NAME, "--paranoia={0}", settings.Paranoia);
AaruLogging.Debug(MODULE_NAME, "--cure-paranoia={0}", settings.CureParanoia);
AaruLogging.Debug(MODULE_NAME, "--raw={0}", settings.Raw);
AaruLogging.Debug(MODULE_NAME, "--start-reverse={0}", settings.StartReverse);
Dictionary<string, string> parsedOptions = Options.Parse(settings.Options);
AaruLogging.Debug(MODULE_NAME, UI.Parsed_options);
@@ -528,7 +529,8 @@ sealed class DumpMediaCommand : Command<DumpMediaCommand.Settings>
(uint)settings.Dimensions,
settings.Paranoia,
settings.CureParanoia,
settings.BypassWiiDecryption);
settings.BypassWiiDecryption,
settings.StartReverse);
AnsiConsole.Progress()
.AutoClear(true)
@@ -801,6 +803,9 @@ sealed class DumpMediaCommand : Command<DumpMediaCommand.Settings>
[LocalizedDescription(nameof(UI.Output_image_path_Dump_help))]
[CommandArgument(1, "<output-path>")]
public string OutputPath { get; init; }
[LocalizedDescription(nameof(UI.Start_reverse_error_retry))]
[CommandOption("--start-reverse")]
public bool StartReverse { get; init; }
}
#endregion