From 8a105cd72d6893cd190adf247f986fa723a027f1 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Fri, 20 Nov 2020 02:42:23 +0000 Subject: [PATCH] Fix retrieving CD drive offsets from database when model or manufacturer contains a slash. Fixes #454 --- Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs | 17 ++++++----- Aaru/Commands/Device/Info.cs | 28 ++++++++++--------- Aaru/Commands/Media/Info.cs | 7 +++-- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs index d773db83f..7b40dc0be 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs @@ -1044,7 +1044,10 @@ namespace Aaru.Core.Devices.Dumping } // Search for read offset in main database - cdOffset = _ctx.CdOffsets.FirstOrDefault(d => d.Manufacturer == _dev.Manufacturer && d.Model == _dev.Model); + cdOffset = + _ctx.CdOffsets.FirstOrDefault(d => (d.Manufacturer == _dev.Manufacturer || + d.Manufacturer == _dev.Manufacturer.Replace('/', '-')) && + (d.Model == _dev.Model || d.Model == _dev.Model.Replace('/', '-'))); Media.Info.CompactDisc.GetOffset(cdOffset, _dbDev, _debug, _dev, dskType, _dumpLog, tracks, UpdateStatus, out int? driveOffset, out int? combinedOffset, out _supportsPlextorD8); @@ -1270,23 +1273,23 @@ namespace Aaru.Core.Devices.Dumping mhddLog.Close(); ibgLog.Close(_dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024, - (blockSize * (double)(blocks + 1)) / 1024 / (totalDuration / 1000), _devicePath); + blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath); UpdateStatus?.Invoke($"Dump finished in {(end - start).TotalSeconds} seconds."); UpdateStatus?. - Invoke($"Average dump speed {((double)blockSize * (double)(blocks + 1)) / 1024 / (totalDuration / 1000):F3} KiB/sec."); + Invoke($"Average dump speed {(double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000):F3} KiB/sec."); UpdateStatus?. - Invoke($"Average write speed {((double)blockSize * (double)(blocks + 1)) / 1024 / imageWriteDuration:F3} KiB/sec."); + Invoke($"Average write speed {(double)blockSize * (double)(blocks + 1) / 1024 / imageWriteDuration:F3} KiB/sec."); _dumpLog.WriteLine("Dump finished in {0} seconds.", (end - start).TotalSeconds); _dumpLog.WriteLine("Average dump speed {0:F3} KiB/sec.", - ((double)blockSize * (double)(blocks + 1)) / 1024 / (totalDuration / 1000)); + (double)blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000)); _dumpLog.WriteLine("Average write speed {0:F3} KiB/sec.", - ((double)blockSize * (double)(blocks + 1)) / 1024 / imageWriteDuration); + (double)blockSize * (double)(blocks + 1) / 1024 / imageWriteDuration); TrimCdUserData(audioExtents, blockSize, currentTry, extents, newTrim, offsetBytes, read6, read10, read12, read16, readcd, sectorsForOffset, subSize, supportedSubchannel, supportsLongSectors, @@ -1420,7 +1423,7 @@ namespace Aaru.Core.Devices.Dumping Invoke($"Took a total of {(end - dumpStart).TotalSeconds:F3} seconds ({totalDuration / 1000:F3} processing commands, {totalChkDuration / 1000:F3} checksumming, {imageWriteDuration:F3} writing, {(closeEnd - closeStart).TotalSeconds:F3} closing)."); UpdateStatus?. - Invoke($"Average speed: {((double)blockSize * (double)(blocks + 1)) / 1048576 / (totalDuration / 1000):F3} MiB/sec."); + Invoke($"Average speed: {(double)blockSize * (double)(blocks + 1) / 1048576 / (totalDuration / 1000):F3} MiB/sec."); if(maxSpeed > 0) UpdateStatus?.Invoke($"Fastest speed burst: {maxSpeed:F3} MiB/sec."); diff --git a/Aaru/Commands/Device/Info.cs b/Aaru/Commands/Device/Info.cs index d40adf20e..5e387e75c 100644 --- a/Aaru/Commands/Device/Info.cs +++ b/Aaru/Commands/Device/Info.cs @@ -836,26 +836,26 @@ namespace Aaru.Commands.Device AaruConsole.WriteLine("Drive has loaded a total of {0} discs", devInfo.PlextorFeatures.Discs); AaruConsole.WriteLine("Drive has spent {0} hours, {1} minutes and {2} seconds reading CDs", - devInfo.PlextorFeatures.CdReadTime / 3600, - (devInfo.PlextorFeatures.CdReadTime / 60) % 60, - devInfo.PlextorFeatures.CdReadTime % 60); + devInfo.PlextorFeatures.CdReadTime / 3600, + devInfo.PlextorFeatures.CdReadTime / 60 % 60, + devInfo.PlextorFeatures.CdReadTime % 60); AaruConsole.WriteLine("Drive has spent {0} hours, {1} minutes and {2} seconds writing CDs", - devInfo.PlextorFeatures.CdWriteTime / 3600, - (devInfo.PlextorFeatures.CdWriteTime / 60) % 60, - devInfo.PlextorFeatures.CdWriteTime % 60); + devInfo.PlextorFeatures.CdWriteTime / 3600, + devInfo.PlextorFeatures.CdWriteTime / 60 % 60, + devInfo.PlextorFeatures.CdWriteTime % 60); if(devInfo.PlextorFeatures.IsDvd) { AaruConsole.WriteLine("Drive has spent {0} hours, {1} minutes and {2} seconds reading DVDs", - devInfo.PlextorFeatures.DvdReadTime / 3600, - (devInfo.PlextorFeatures.DvdReadTime / 60) % 60, - devInfo.PlextorFeatures.DvdReadTime % 60); + devInfo.PlextorFeatures.DvdReadTime / 3600, + devInfo.PlextorFeatures.DvdReadTime / 60 % 60, + devInfo.PlextorFeatures.DvdReadTime % 60); AaruConsole.WriteLine("Drive has spent {0} hours, {1} minutes and {2} seconds writing DVDs", - devInfo.PlextorFeatures.DvdWriteTime / 3600, - (devInfo.PlextorFeatures.DvdWriteTime / 60) % 60, - devInfo.PlextorFeatures.DvdWriteTime % 60); + devInfo.PlextorFeatures.DvdWriteTime / 3600, + devInfo.PlextorFeatures.DvdWriteTime / 60 % 60, + devInfo.PlextorFeatures.DvdWriteTime % 60); } } @@ -1159,7 +1159,9 @@ namespace Aaru.Commands.Device // Search for read offset in main database CdOffset cdOffset = - ctx.CdOffsets.FirstOrDefault(d => d.Manufacturer == dev.Manufacturer && d.Model == dev.Model); + ctx.CdOffsets.FirstOrDefault(d => (d.Manufacturer == dev.Manufacturer || + d.Manufacturer == dev.Manufacturer.Replace('/', '-')) && + (d.Model == dev.Model || d.Model == dev.Model.Replace('/', '-'))); AaruConsole.WriteLine(cdOffset is null ? "CD reading offset not found in database." : $"CD reading offset is {cdOffset.Offset} samples ({cdOffset.Offset * 4} bytes)."); diff --git a/Aaru/Commands/Media/Info.cs b/Aaru/Commands/Media/Info.cs index 270d4e56c..d31333f32 100644 --- a/Aaru/Commands/Media/Info.cs +++ b/Aaru/Commands/Media/Info.cs @@ -608,8 +608,11 @@ namespace Aaru.Commands.Media AaruConsole.WriteLine("Offsets:"); // Search for read offset in main database - CdOffset cdOffset = ctx.CdOffsets.FirstOrDefault(d => d.Manufacturer == dev.Manufacturer && - d.Model == dev.Model); + CdOffset cdOffset = + ctx.CdOffsets.FirstOrDefault(d => (d.Manufacturer == dev.Manufacturer || + d.Manufacturer == dev.Manufacturer.Replace('/', '-')) && + (d.Model == dev.Model || + d.Model == dev.Model.Replace('/', '-'))); CompactDisc.GetOffset(cdOffset, dbDev, debug, dev, scsiInfo.MediaType, null, tracks, null, out int? driveOffset, out int? combinedOffset, out _);