mirror of
https://github.com/aaru-dps/Aaru.git
synced 2026-07-08 17:56:18 +00:00
Add error recovery support and related logging
This commit is contained in:
@@ -44,6 +44,7 @@ using Aaru.CommonTypes.Enums;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.CommonTypes.Metadata;
|
||||
using Aaru.Core;
|
||||
using Aaru.Images;
|
||||
using Aaru.Localization;
|
||||
using Aaru.Logging;
|
||||
using Schemas;
|
||||
@@ -234,6 +235,23 @@ sealed class ConvertImageCommand : Command<ConvertImageCommand.Settings>
|
||||
|
||||
if(outputFormat == null) return (int)ErrorNumber.FormatNotFound;
|
||||
|
||||
if(settings.ErrorRecovery > 0)
|
||||
{
|
||||
if(outputFormat is not AaruFormat)
|
||||
{
|
||||
AaruLogging.Error(UI.Error_recovery_is_only_supported_in_AaruFormat);
|
||||
|
||||
return (int)ErrorNumber.NotSupported;
|
||||
}
|
||||
|
||||
if(settings.ErrorRecovery > 100)
|
||||
{
|
||||
AaruLogging.Error(UI.Maximum_error_recovery_is_100);
|
||||
|
||||
return (int)ErrorNumber.InvalidArgument;
|
||||
}
|
||||
}
|
||||
|
||||
if(settings.Verbose)
|
||||
AaruLogging.Verbose(UI.Output_image_format_0_1, outputFormat.Name, outputFormat.Id);
|
||||
else
|
||||
@@ -274,7 +292,8 @@ sealed class ConvertImageCommand : Command<ConvertImageCommand.Settings>
|
||||
settings.BypassPs3Decryption,
|
||||
settings.BypassWiiuDecryption,
|
||||
settings.BypassWiiDecryption,
|
||||
settings.InputPath);
|
||||
settings.InputPath,
|
||||
settings.ErrorRecovery);
|
||||
|
||||
ErrorNumber errno = ErrorNumber.NoError;
|
||||
|
||||
@@ -560,6 +579,7 @@ sealed class ConvertImageCommand : Command<ConvertImageCommand.Settings>
|
||||
AaruLogging.Debug(MODULE_NAME, "--aaru-metadata={0}", Markup.Escape(settings.AaruMetadata ?? ""));
|
||||
AaruLogging.Debug(MODULE_NAME, "--ignore-negative-sectors={0}", settings.IgnoreNegativeSectors);
|
||||
AaruLogging.Debug(MODULE_NAME, "--ignore-overflow-sectors={0}", settings.IgnoreOverflowSectors);
|
||||
AaruLogging.Debug(MODULE_NAME, "--error-recovery={0}", settings.ErrorRecovery);
|
||||
|
||||
AaruLogging.Debug(MODULE_NAME, UI.Parsed_options);
|
||||
|
||||
@@ -758,5 +778,9 @@ sealed class ConvertImageCommand : Command<ConvertImageCommand.Settings>
|
||||
[DefaultValue(false)]
|
||||
[CommandOption("--ignore-overflow-sectors")]
|
||||
public bool IgnoreOverflowSectors { get; init; }
|
||||
[LocalizedDescription(nameof(UI.Add_error_recovery))]
|
||||
[DefaultValue(0)]
|
||||
[CommandOption("--error-recovery")]
|
||||
public int ErrorRecovery { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,8 @@ class MergeCommand : AsyncCommand<MergeCommand.Settings>
|
||||
settings.GenerateSubchannels,
|
||||
settings.Decrypt,
|
||||
settings.IgnoreNegativeSectors,
|
||||
settings.IgnoreOverflowSectors);
|
||||
settings.IgnoreOverflowSectors,
|
||||
settings.ErrorRecovery);
|
||||
|
||||
ErrorNumber errno = ErrorNumber.NoError;
|
||||
|
||||
@@ -188,6 +189,7 @@ class MergeCommand : AsyncCommand<MergeCommand.Settings>
|
||||
AaruLogging.Debug(MODULE_NAME, "--sectors-file={0}", Markup.Escape(settings.SectorsFile ?? ""));
|
||||
AaruLogging.Debug(MODULE_NAME, "--ignore-negative-sectors={0}", settings.IgnoreNegativeSectors);
|
||||
AaruLogging.Debug(MODULE_NAME, "--ignore-overflow-sectors={0}", settings.IgnoreOverflowSectors);
|
||||
AaruLogging.Debug(MODULE_NAME, "--error-recovery={0}", settings.ErrorRecovery);
|
||||
|
||||
AaruLogging.Debug(MODULE_NAME, UI.Parsed_options);
|
||||
|
||||
@@ -326,5 +328,9 @@ class MergeCommand : AsyncCommand<MergeCommand.Settings>
|
||||
[DefaultValue(false)]
|
||||
[CommandOption("--ignore-overflow-sectors")]
|
||||
public bool IgnoreOverflowSectors { get; init; }
|
||||
[LocalizedDescription(nameof(UI.Add_error_recovery))]
|
||||
[DefaultValue(0)]
|
||||
[CommandOption("--error-recovery")]
|
||||
public int ErrorRecovery { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,7 @@ using Aaru.CommonTypes.Structs.Devices.SCSI;
|
||||
using Aaru.Core;
|
||||
using Aaru.Core.Devices.Dumping;
|
||||
using Aaru.Core.Logging;
|
||||
using Aaru.Images;
|
||||
using Aaru.Localization;
|
||||
using Aaru.Logging;
|
||||
using Schemas;
|
||||
@@ -126,6 +127,7 @@ sealed class DumpMediaCommand : Command<DumpMediaCommand.Settings>
|
||||
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);
|
||||
AaruLogging.Debug(MODULE_NAME, "--error-recovery={0}", settings.ErrorRecovery);
|
||||
|
||||
Dictionary<string, string> parsedOptions = Options.Parse(settings.Options);
|
||||
AaruLogging.Debug(MODULE_NAME, UI.Parsed_options);
|
||||
@@ -480,6 +482,23 @@ sealed class DumpMediaCommand : Command<DumpMediaCommand.Settings>
|
||||
|
||||
IBaseWritableImage outputFormat = candidates[0];
|
||||
|
||||
if(settings.ErrorRecovery > 0)
|
||||
{
|
||||
if(outputFormat is not AaruFormat)
|
||||
{
|
||||
AaruLogging.Error(UI.Error_recovery_is_only_supported_in_AaruFormat);
|
||||
|
||||
return (int)ErrorNumber.NotSupported;
|
||||
}
|
||||
|
||||
if(settings.ErrorRecovery > 100)
|
||||
{
|
||||
AaruLogging.Error(UI.Maximum_error_recovery_is_100);
|
||||
|
||||
return (int)ErrorNumber.InvalidArgument;
|
||||
}
|
||||
}
|
||||
|
||||
DeviceLog.StartLog(dev, settings.Private);
|
||||
|
||||
if(settings.Verbose)
|
||||
@@ -530,7 +549,8 @@ sealed class DumpMediaCommand : Command<DumpMediaCommand.Settings>
|
||||
settings.Paranoia,
|
||||
settings.CureParanoia,
|
||||
settings.BypassWiiDecryption,
|
||||
settings.StartReverse);
|
||||
settings.StartReverse,
|
||||
settings.ErrorRecovery);
|
||||
|
||||
AnsiConsole.Progress()
|
||||
.AutoClear(true)
|
||||
@@ -806,6 +826,10 @@ sealed class DumpMediaCommand : Command<DumpMediaCommand.Settings>
|
||||
[LocalizedDescription(nameof(UI.Start_reverse_error_retry))]
|
||||
[CommandOption("--start-reverse")]
|
||||
public bool StartReverse { get; init; }
|
||||
[LocalizedDescription(nameof(UI.Add_error_recovery))]
|
||||
[DefaultValue(0)]
|
||||
[CommandOption("--error-recovery")]
|
||||
public int ErrorRecovery { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user