outputFormat null-check

This commit is contained in:
Rebecca Wallander
2026-04-03 16:33:11 +02:00
parent cb16dc0642
commit 7166ade598
3 changed files with 29 additions and 1 deletions

View File

@@ -306,6 +306,14 @@ partial class Dump
_resume.BadBlocks.Remove(badSector);
extents.Add(badSector);
if(outputFormat is null)
{
ErrorMessage?.Invoke(string.Format(Localization.Core.Cannot_write_retried_sector_0_no_writable_output_image,
badSector));
continue;
}
if(scsiReader.ReadBuffer3CReadRaw || scsiReader.OmniDriveReadRaw || scsiReader.HldtstReadRaw)
{
if(_ngcwEnabled)
@@ -368,7 +376,18 @@ partial class Dump
badSector,
pass));
}
else if(runningPersistent) outputFormat.WriteSector(buffer, badSector, false, SectorStatus.Errored);
else if(runningPersistent)
{
if(outputFormat is null)
{
ErrorMessage?.Invoke(string.Format(Localization.Core.Cannot_write_retried_sector_0_no_writable_output_image,
badSector));
continue;
}
outputFormat.WriteSector(buffer, badSector, false, SectorStatus.Errored);
}
}
if(pass < _retryPasses && !_aborted && _resume.BadBlocks.Count > 0)

View File

@@ -3113,6 +3113,12 @@ namespace Aaru.Localization {
}
}
public static string Cannot_write_retried_sector_0_no_writable_output_image {
get {
return ResourceManager.GetString("Cannot_write_retried_sector_0_no_writable_output_image", resourceCulture);
}
}
public static string Cannot_write_SCR_to_output_image {
get {
return ResourceManager.GetString("Cannot_write_SCR_to_output_image", resourceCulture);

View File

@@ -1126,6 +1126,9 @@
<data name="Image_is_not_writable_aborting" xml:space="preserve">
<value>[red]Image is not writable, aborting...[/]</value>
</data>
<data name="Cannot_write_retried_sector_0_no_writable_output_image" xml:space="preserve">
<value>[red]Cannot write retried sector [lime]{0}[/]: output is not a writable image.[/]</value>
</data>
<data name="Could_not_detect_capacity" xml:space="preserve">
<value>[red]Could not detect capacity...[/]</value>
</data>