Allow user to choose maximum number of block to read at once when dumping media.

This commit is contained in:
2020-10-17 00:21:42 +01:00
parent 3f9a0631f0
commit 4dcf5dd979
3 changed files with 26 additions and 11 deletions

View File

@@ -127,13 +127,14 @@ namespace Aaru.Core.Devices.Dumping
/// <param name="skipCdireadyHole">Skip gap between CD-i Ready hidden track and track 1 audio</param>
/// <param name="errorLog">Error log</param>
/// <param name="generateSubchannels">Generate missing subchannels</param>
/// <param name="maximumReadable">Number of maximum blocks to be read at once (can be overriden by database)</param>
public Dump(bool doResume, Device dev, string devicePath, IWritableImage outputPlugin, ushort retryPasses,
bool force, bool dumpRaw, bool persistent, bool stopOnError, Resume resume, DumpLog dumpLog,
Encoding encoding, string outputPrefix, string outputPath, Dictionary<string, string> formatOptions,
CICMMetadataType preSidecar, uint skip, bool metadata, bool trim, bool dumpFirstTrackPregap,
bool fixOffset, bool debug, DumpSubchannel subchannel, int speed, bool @private,
bool fixSubchannelPosition, bool retrySubchannel, bool fixSubchannel, bool fixSubchannelCrc,
bool skipCdireadyHole, ErrorLog errorLog, bool generateSubchannels)
bool skipCdireadyHole, ErrorLog errorLog, bool generateSubchannels, uint maximumReadable)
{
_doResume = doResume;
_dev = dev;
@@ -158,7 +159,7 @@ namespace Aaru.Core.Devices.Dumping
_aborted = false;
_fixOffset = fixOffset;
_debug = debug;
_maximumReadable = 64;
_maximumReadable = maximumReadable;
_subchannel = subchannel;
_speedMultiplier = -1;
_speed = speed;

View File

@@ -810,7 +810,7 @@ namespace Aaru.Gui.ViewModels.Windows
Persistent, StopOnError, _resume, dumpLog, encoding, _outputPrefix, Destination,
parsedOptions, _sidecar, (uint)Skipped, ExistingMetadata == false, Trim == false,
Track1Pregap, true, false, DumpSubchannel.Any, 0, false, false, false, false, false,
true, errorLog, false);
true, errorLog, false, 64);
new Thread(DoWork).Start();
}

View File

@@ -271,6 +271,15 @@ namespace Aaru.Commands.Media
Required = false
});
Add(new Option(new[]
{
"--max-blocks"
}, "Maximum number of blocks to read at once.")
{
Argument = new Argument<uint>(() => 64),
Required = false
});
Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke)));
}
@@ -279,7 +288,8 @@ namespace Aaru.Commands.Media
bool trim, string outputPath, string options, bool persistent, ushort retryPasses,
uint skip, byte speed, bool stopOnError, string format, string subchannel,
bool @private, bool fixSubchannelPosition, bool retrySubchannel, bool fixSubchannel,
bool fixSubchannelCrc, bool generateSubchannels, bool skipCdiReadyHole, bool eject)
bool fixSubchannelCrc, bool generateSubchannels, bool skipCdiReadyHole, bool eject,
uint maxBlocks)
{
MainClass.PrintCopyright();
@@ -295,6 +305,9 @@ namespace Aaru.Commands.Media
if(retrySubchannel || fixSubchannel)
fixSubchannelPosition = true;
if(maxBlocks == 0)
maxBlocks = 64;
Statistics.AddCommand("dump-media");
AaruConsole.DebugWriteLine("Dump-Media command", "--cicm-xml={0}", cicmXml);
@@ -324,6 +337,7 @@ namespace Aaru.Commands.Media
AaruConsole.DebugWriteLine("Dump-Media command", "--generate-subchannels={0}", generateSubchannels);
AaruConsole.DebugWriteLine("Dump-Media command", "--skip-cdiready-hole={0}", skipCdiReadyHole);
AaruConsole.DebugWriteLine("Dump-Media command", "--eject={0}", eject);
AaruConsole.DebugWriteLine("Dump-Media command", "--max-blocks={0}", maxBlocks);
// TODO: Disabled temporarily
//AaruConsole.DebugWriteLine("Dump-Media command", "--raw={0}", raw);
@@ -414,8 +428,8 @@ namespace Aaru.Commands.Media
// Try name
else
candidates.AddRange(plugins.WritableImages.Values.Where(t => string.Equals(t.Name, format,
StringComparison.
InvariantCultureIgnoreCase)));
StringComparison.
InvariantCultureIgnoreCase)));
if(candidates.Count == 0)
{
@@ -575,8 +589,8 @@ namespace Aaru.Commands.Media
if(string.IsNullOrEmpty(format))
candidates.AddRange(plugins.WritableImages.Values.Where(t =>
t.KnownExtensions.
Contains(Path.
GetExtension(outputPath))));
Contains(Path.
GetExtension(outputPath))));
// Try Id
else if(Guid.TryParse(format, out Guid outId))
@@ -585,8 +599,8 @@ namespace Aaru.Commands.Media
// Try name
else
candidates.AddRange(plugins.WritableImages.Values.Where(t => string.Equals(t.Name, format,
StringComparison.
InvariantCultureIgnoreCase)));
StringComparison.
InvariantCultureIgnoreCase)));
IWritableImage outputFormat = candidates[0];
@@ -610,7 +624,7 @@ namespace Aaru.Commands.Media
outputPrefix + extension, parsedOptions, sidecar, skip, metadata, trim,
firstPregap, fixOffset, debug, wantedSubchannel, speed, @private,
fixSubchannelPosition, retrySubchannel, fixSubchannel, fixSubchannelCrc,
skipCdiReadyHole, errorLog, generateSubchannels);
skipCdiReadyHole, errorLog, generateSubchannels, maxBlocks);
dumper.UpdateStatus += Progress.UpdateStatus;
dumper.ErrorMessage += Progress.ErrorMessage;