From 8786474169909e92be5d556e7f019d855133d46c Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Tue, 26 Sep 2023 10:51:43 +0100 Subject: [PATCH] Fix byte speed rates not being properly "humanized". --- Aaru.Core/Devices/Dumping/ATA.cs | 26 ++++++++++++------- .../Devices/Dumping/CompactDisc/CdiReady.cs | 12 ++++----- Aaru.Core/Devices/Dumping/CompactDisc/Data.cs | 12 ++++----- Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs | 7 ++--- .../Devices/Dumping/CompactDisc/LeadOuts.cs | 4 +-- .../Devices/Dumping/CompactDisc/Pregap.cs | 2 +- .../Devices/Dumping/LinearMemory/Retrode.cs | 19 ++++++++------ Aaru.Core/Devices/Dumping/Metadata.cs | 3 ++- Aaru.Core/Devices/Dumping/MiniDisc.cs | 14 +++++----- .../PlayStationPortable/MemoryStick.cs | 14 +++++----- .../Dumping/PlayStationPortable/UMD.cs | 11 ++++---- Aaru.Core/Devices/Dumping/SSC.cs | 12 +++++---- Aaru.Core/Devices/Dumping/Sbc/Data.cs | 2 +- Aaru.Core/Devices/Dumping/Sbc/Dump.cs | 7 ++--- Aaru.Core/Devices/Dumping/Sbc/Optical.cs | 2 +- Aaru.Core/Devices/Dumping/SecureDigital.cs | 12 +++++---- Aaru.Core/Devices/Dumping/XGD.cs | 12 ++++----- Aaru.Core/Devices/Scanning/ATA.cs | 5 ++-- Aaru.Core/Devices/Scanning/SCSI.cs | 4 +-- Aaru.Core/Devices/Scanning/SecureDigital.cs | 2 +- .../ViewModels/Windows/MediaScanViewModel.cs | 8 +++--- Aaru/Commands/Media/Scan.cs | 7 ++--- 22 files changed, 110 insertions(+), 87 deletions(-) diff --git a/Aaru.Core/Devices/Dumping/ATA.cs b/Aaru.Core/Devices/Dumping/ATA.cs index 89226824d..52ba20a9e 100644 --- a/Aaru.Core/Devices/Dumping/ATA.cs +++ b/Aaru.Core/Devices/Dumping/ATA.cs @@ -326,7 +326,7 @@ void Ata() minSpeed = currentSpeed; UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i, (long)blocks); bool error = ataReader.ReadBlocks(out cmdBuf, i, blocksToRead, out duration, out _, out _); @@ -397,11 +397,12 @@ void Ata() (end - start).Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalDuration.Milliseconds())); + ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalDuration.Milliseconds()). + Humanize()); _dumpLog.WriteLine(string.Format(Localization.Core.Average_write_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()))); + Per(imageWriteDuration.Seconds()).Humanize())); #region Trimming if(_resume.BadBlocks.Count > 0 && @@ -592,7 +593,9 @@ void Ata() PulseProgress?. Invoke(string.Format(Localization.Core.Reading_cylinder_0_head_1_sector_2_3, cy, hd, - sc, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond))); + sc, + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond). + Humanize())); bool error = ataReader.ReadChs(out cmdBuf, cy, hd, sc, out duration, out recoveredError); @@ -668,10 +671,12 @@ void Ata() (end - start).Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalDuration.Milliseconds())); + ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalDuration.Milliseconds()). + Humanize()); _dumpLog.WriteLine(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)).Per(imageWriteDuration.Seconds())); + ByteSize.FromBytes(blockSize * (blocks + 1)).Per(imageWriteDuration.Seconds()). + Humanize()); } foreach(ulong bad in _resume.BadBlocks) @@ -866,7 +871,8 @@ void Ata() (chkEnd - chkStart).Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds())); + ByteSize.FromBytes(blockSize * (blocks + 1)). + Per(totalChkDuration.Milliseconds()).Humanize()); List<(ulong start, string type)> filesystems = new(); @@ -940,15 +946,15 @@ from fileSystem in partition.FileSystems UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds()).Humanize())); if(maxSpeed > 0) UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, - ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond))); + ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond).Humanize())); if(minSpeed is > 0 and < double.MaxValue) UpdateStatus?.Invoke(string.Format(Localization.Core.Slowest_speed_burst_0, - ByteSize.FromMegabytes(minSpeed).Per(_oneSecond))); + ByteSize.FromMegabytes(minSpeed).Per(_oneSecond).Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core._0_sectors_could_not_be_read, _resume.BadBlocks.Count)); diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs b/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs index 9f6c75545..925e0f6be 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/CdiReady.cs @@ -216,7 +216,7 @@ void ReadCdiReady(uint blockSize, ref double currentSpeed, DumpHardware currentT minSpeed = currentSpeed; UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i, (long)blocks); sense = _dev.ReadCd(out cmdBuf, out senseBuf, firstSectorToRead, blockSize, blocksToRead, @@ -232,7 +232,7 @@ void ReadCdiReady(uint blockSize, ref double currentSpeed, DumpHardware currentT for(uint r = 0; r < _maximumReadable; r++) { UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i + r, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i + r, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i + r, (long)blocks); sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)(i + r), blockSize, (uint)sectorsForOffset + 1, @@ -354,10 +354,10 @@ void ReadCdiReady(uint blockSize, ref double currentSpeed, DumpHardware currentT outputOptical.WriteSectorsLong(data, i, blocksToRead); bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, - desiredSubchannel, sub, i, blocksToRead, subLog, isrcs, 1, ref mcn, tracks, - subchannelExtents, _fixSubchannelPosition, outputOptical, _fixSubchannel, - _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true, - out List newPregapSectors); + desiredSubchannel, sub, i, blocksToRead, subLog, isrcs, 1, ref mcn, tracks, + subchannelExtents, _fixSubchannelPosition, outputOptical, _fixSubchannel, + _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true, + out List newPregapSectors); // Set tracks and go back if(indexesChanged) diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs index bae65d720..ccdcf8894 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Data.cs @@ -273,7 +273,7 @@ void ReadCdData(ExtentsULong audioExtents, ulong blocks, uint blockSize, ref dou minSpeed = currentSpeed; UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i, (long)blocks); if(crossingLeadOut && @@ -425,7 +425,7 @@ void ReadCdData(ExtentsULong audioExtents, ulong blocks, uint blockSize, ref dou for(uint r = 0; r < blocksToRead; r++) { UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i + r, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i + r, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i + r, (long)blocks); if(_supportsPlextorD8) @@ -673,10 +673,10 @@ void ReadCdData(ExtentsULong audioExtents, ulong blocks, uint blockSize, ref dou } bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel, - desiredSubchannel, sub, i, blocksToRead, subLog, isrcs, (byte)track.Sequence, ref mcn, - tracks, subchannelExtents, _fixSubchannelPosition, outputFormat as IWritableOpticalImage, - _fixSubchannel, _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true, - out List newPregapSectors); + desiredSubchannel, sub, i, blocksToRead, subLog, isrcs, (byte)track.Sequence, ref mcn, + tracks, subchannelExtents, _fixSubchannelPosition, outputFormat as IWritableOpticalImage, + _fixSubchannel, _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true, + out List newPregapSectors); // Set tracks and go back if(indexesChanged) diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs index a49745972..e939202e2 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs @@ -1474,14 +1474,15 @@ void CompactDisc() UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds()).Humanize())); if(maxSpeed > 0) - UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond))); + UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, + ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond).Humanize())); if(minSpeed is > 0 and < double.MaxValue) UpdateStatus?.Invoke(string.Format(Localization.Core.Slowest_speed_burst_0, - ByteSize.FromMegabytes(minSpeed).Per(_oneSecond))); + ByteSize.FromMegabytes(minSpeed).Per(_oneSecond).Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core._0_sectors_could_not_be_read, _resume.BadBlocks.Count)); diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs b/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs index b51afc1b3..f3aaa2a64 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/LeadOuts.cs @@ -122,7 +122,7 @@ void DumpCdLeadOuts(uint blockSize, ref double currentSpeed, DumpHardware curren minSpeed = currentSpeed; PulseProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_at_lead_out_1, i, - ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond))); + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize())); if(readcd) { @@ -294,7 +294,7 @@ void RetryCdLeadOuts(uint blockSize, ref double currentSpeed, DumpHardware curre minSpeed = currentSpeed; PulseProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_at_lead_out_1, i, - ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond))); + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize())); if(readcd) { diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs index 0c467ac94..d07177dd3 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Pregap.cs @@ -89,7 +89,7 @@ void ReadCdFirstTrackPregap(uint blockSize, ref double currentSpeed, Dictionary< PulseProgress?.Invoke(string.Format(Localization.Core.Trying_to_read_first_track_pregap_sector_0_1, firstTrackPregapBlock, - ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond))); + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize())); // ReSharper disable IntVariableOverflowInUncheckedContext sense = _dev.ReadCd(out cmdBuf, out _, (uint)firstTrackPregapBlock, blockSize, 1, MmcSectorTypes.AllTypes, diff --git a/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs b/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs index 44d545a80..85ba5ab27 100644 --- a/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs +++ b/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs @@ -321,7 +321,7 @@ void Retrode() minSpeed = currentSpeed; UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_byte_0_of_1_2, i * 512, romSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_byte_0_of_1_2, i * 512, romSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i * 512, romSize); sense = _dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)(startSector + i), @@ -373,7 +373,7 @@ void Retrode() minSpeed = currentSpeed; UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_byte_0_of_1_2, romSectors * 512, romSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_byte_0_of_1_2, romSectors * 512, romSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)romSectors * 512, romSize); sense = _dev.Read10(out readBuffer, out senseBuf, 0, false, true, false, false, romSectors, 512, 0, 1, @@ -417,10 +417,12 @@ void Retrode() _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, (end - start).Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(512 * (romSectors + 1)).Per(totalDuration.Milliseconds()))); + ByteSize.FromBytes(512 * (romSectors + 1)).Per(totalDuration.Milliseconds()). + Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(512 * (romSectors + 1)).Per(imageWriteDuration.Seconds()))); + ByteSize.FromBytes(512 * (romSectors + 1)).Per(imageWriteDuration.Seconds()). + Humanize())); var metadata = new CommonTypes.Structs.ImageInfo { @@ -470,15 +472,16 @@ void Retrode() (closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, - ByteSize.FromBytes(512 * (romSectors + 1)). - Per(totalDuration.Milliseconds()))); + ByteSize.FromBytes(512 * (romSectors + 1)).Per(totalDuration.Milliseconds()). + Humanize())); if(maxSpeed > 0) - UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond))); + UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, + ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond).Humanize())); if(minSpeed is > 0 and < double.MaxValue) UpdateStatus?.Invoke(string.Format(Localization.Core.Slowest_speed_burst_0, - ByteSize.FromMegabytes(minSpeed).Per(_oneSecond))); + ByteSize.FromMegabytes(minSpeed).Per(_oneSecond).Humanize())); UpdateStatus?.Invoke(""); diff --git a/Aaru.Core/Devices/Dumping/Metadata.cs b/Aaru.Core/Devices/Dumping/Metadata.cs index 0b8a0fb8c..dd9d9bf57 100644 --- a/Aaru.Core/Devices/Dumping/Metadata.cs +++ b/Aaru.Core/Devices/Dumping/Metadata.cs @@ -102,7 +102,8 @@ void WriteOpticalSidecar(uint blockSize, ulong blocks, MediaType mediaType, Laye _dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, (end - chkStart).Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds())); + ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()). + Humanize()); if(_preSidecar != null) { diff --git a/Aaru.Core/Devices/Dumping/MiniDisc.cs b/Aaru.Core/Devices/Dumping/MiniDisc.cs index 867e9dcfe..2f2ea5a8f 100644 --- a/Aaru.Core/Devices/Dumping/MiniDisc.cs +++ b/Aaru.Core/Devices/Dumping/MiniDisc.cs @@ -378,7 +378,7 @@ void MiniDisc() minSpeed = currentSpeed; UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i, (long)blocks); sense = _dev.Read6(out readBuffer, out _, (uint)i, blockSize, (byte)blocksToRead, _dev.Timeout, @@ -539,7 +539,7 @@ void MiniDisc() if(dcMode6?.Pages != null) foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => - modePage is { Page: 0x01, Subpage: 0x00 })) + modePage is { Page: 0x01, Subpage: 0x00 })) currentModePage = modePage; } @@ -789,7 +789,8 @@ void MiniDisc() (end - chkStart).Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds())); + ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()). + Humanize()); if(_preSidecar != null) { @@ -873,14 +874,15 @@ void MiniDisc() UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds()).Humanize())); if(maxSpeed > 0) - UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond))); + UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, + ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond).Humanize())); if(minSpeed is > 0 and < double.MaxValue) UpdateStatus?.Invoke(string.Format(Localization.Core.Slowest_speed_burst_0, - ByteSize.FromMegabytes(minSpeed).Per(_oneSecond))); + ByteSize.FromMegabytes(minSpeed).Per(_oneSecond).Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core._0_sectors_could_not_be_read, _resume.BadBlocks.Count)); UpdateStatus?.Invoke(""); diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs index 40674af28..ec2310eaf 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs @@ -211,7 +211,7 @@ void DumpMs() minSpeed = currentSpeed; UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i, blocks); sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)i, blockSize, 0, @@ -391,7 +391,7 @@ void DumpMs() if(dcMode6.HasValue) foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => - modePage is { Page: 0x01, Subpage: 0x00 })) + modePage is { Page: 0x01, Subpage: 0x00 })) currentModePage = modePage; } @@ -643,7 +643,8 @@ void DumpMs() (end - chkStart).Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds())); + ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()). + Humanize()); if(_preSidecar != null) { @@ -716,14 +717,15 @@ void DumpMs() UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds()).Humanize())); if(maxSpeed > 0) - UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond))); + UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, + ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond).Humanize())); if(minSpeed is > 0 and < double.MaxValue) UpdateStatus?.Invoke(string.Format(Localization.Core.Slowest_speed_burst_0, - ByteSize.FromMegabytes(minSpeed).Per(_oneSecond))); + ByteSize.FromMegabytes(minSpeed).Per(_oneSecond).Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core._0_sectors_could_not_be_read, _resume.BadBlocks.Count)); UpdateStatus?.Invoke(""); diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs index 448484543..812d13725 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs @@ -233,7 +233,7 @@ void DumpUmd() minSpeed = currentSpeed; UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i, (long)blocks); sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, true, false, false, (uint)(umdStart + (i * 4)), @@ -396,7 +396,7 @@ void DumpUmd() if(dcMode6.HasValue) foreach(Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage => - modePage is { Page: 0x01, Subpage: 0x00 })) + modePage is { Page: 0x01, Subpage: 0x00 })) currentModePage = modePage; } @@ -617,14 +617,15 @@ void DumpUmd() UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds()).Humanize())); if(maxSpeed > 0) - UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond))); + UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, + ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond).Humanize())); if(minSpeed is > 0 and < double.MaxValue) UpdateStatus?.Invoke(string.Format(Localization.Core.Slowest_speed_burst_0, - ByteSize.FromMegabytes(minSpeed).Per(_oneSecond))); + ByteSize.FromMegabytes(minSpeed).Per(_oneSecond).Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core._0_sectors_could_not_be_read, _resume.BadBlocks.Count)); UpdateStatus?.Invoke(""); diff --git a/Aaru.Core/Devices/Dumping/SSC.cs b/Aaru.Core/Devices/Dumping/SSC.cs index a16ef856a..267371f81 100644 --- a/Aaru.Core/Devices/Dumping/SSC.cs +++ b/Aaru.Core/Devices/Dumping/SSC.cs @@ -898,7 +898,7 @@ void Ssc() minSpeed = currentSpeed; PulseProgress?.Invoke(string.Format(Localization.Core.Reading_block_0_1, currentBlock, - ByteSize.FromBytes(currentSpeed).Per(_oneSecond))); + ByteSize.FromBytes(currentSpeed).Per(_oneSecond).Humanize())); sense = _dev.Read6(out cmdBuf, out senseBuf, false, fixedLen, transferLen, blockSize, _dev.Timeout, out duration); @@ -1393,7 +1393,8 @@ void Ssc() (end - chkStart).Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds())); + ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()). + Humanize()); if(_preSidecar != null) { @@ -1478,14 +1479,15 @@ void Ssc() UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds()).Humanize())); if(maxSpeed > 0) - UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond))); + UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, + ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond).Humanize())); if(minSpeed is > 0 and < double.MaxValue) UpdateStatus?.Invoke(string.Format(Localization.Core.Slowest_speed_burst_0, - ByteSize.FromMegabytes(minSpeed).Per(_oneSecond))); + ByteSize.FromMegabytes(minSpeed).Per(_oneSecond).Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core._0_sectors_could_not_be_read, _resume.BadBlocks.Count)); UpdateStatus?.Invoke(""); diff --git a/Aaru.Core/Devices/Dumping/Sbc/Data.cs b/Aaru.Core/Devices/Dumping/Sbc/Data.cs index bb14877f8..87ee8d9ec 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Data.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Data.cs @@ -101,7 +101,7 @@ void ReadSbcData(in ulong blocks, in uint maxBlocksToRead, in uint blockSize, Du minSpeed = currentSpeed; UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i, (long)blocks); sense = scsiReader.ReadBlocks(out buffer, i, blocksToRead, out double cmdDuration, out _, out _); diff --git a/Aaru.Core/Devices/Dumping/Sbc/Dump.cs b/Aaru.Core/Devices/Dumping/Sbc/Dump.cs index 6661cffd5..09a31ce70 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Dump.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Dump.cs @@ -1303,14 +1303,15 @@ from fileSystem in partition.FileSystems UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds())).Humanize()); if(maxSpeed > 0) - UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond))); + UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, + ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond).Humanize())); if(minSpeed is > 0 and < double.MaxValue) UpdateStatus?.Invoke(string.Format(Localization.Core.Slowest_speed_burst_0, - ByteSize.FromMegabytes(minSpeed).Per(_oneSecond))); + ByteSize.FromMegabytes(minSpeed).Per(_oneSecond).Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core._0_sectors_could_not_be_read, _resume.BadBlocks.Count)); UpdateStatus?.Invoke(""); diff --git a/Aaru.Core/Devices/Dumping/Sbc/Optical.cs b/Aaru.Core/Devices/Dumping/Sbc/Optical.cs index f02875ce5..05555d3a1 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Optical.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Optical.cs @@ -208,7 +208,7 @@ void ReadOpticalData(in ulong blocks, in uint maxBlocksToRead, in uint blockSize minSpeed = currentSpeed; UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i, (long)blocks); sense = scsiReader.ReadBlocks(out buffer, i, blocksToRead, out double cmdDuration, out _, out _); diff --git a/Aaru.Core/Devices/Dumping/SecureDigital.cs b/Aaru.Core/Devices/Dumping/SecureDigital.cs index dc32c6bbc..8ab21ca8c 100644 --- a/Aaru.Core/Devices/Dumping/SecureDigital.cs +++ b/Aaru.Core/Devices/Dumping/SecureDigital.cs @@ -651,7 +651,7 @@ void SecureDigital() minSpeed = currentSpeed; UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i, (long)blocks); if(blocksToRead == 1) @@ -951,7 +951,8 @@ void SecureDigital() (end - chkStart).Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds())); + ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()). + Humanize()); (string type, string subType) xmlType = (null, null); @@ -1011,14 +1012,15 @@ void SecureDigital() UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds()).Humanize())); if(maxSpeed > 0) - UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond))); + UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, + ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond).Humanize())); if(minSpeed is > 0 and < double.MaxValue) UpdateStatus?.Invoke(string.Format(Localization.Core.Slowest_speed_burst_0, - ByteSize.FromMegabytes(minSpeed).Per(_oneSecond))); + ByteSize.FromMegabytes(minSpeed).Per(_oneSecond).Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core._0_sectors_could_not_be_read, _resume.BadBlocks.Count)); UpdateStatus?.Invoke(""); diff --git a/Aaru.Core/Devices/Dumping/XGD.cs b/Aaru.Core/Devices/Dumping/XGD.cs index f51d6d252..4ee983b70 100644 --- a/Aaru.Core/Devices/Dumping/XGD.cs +++ b/Aaru.Core/Devices/Dumping/XGD.cs @@ -649,7 +649,7 @@ void Xgd(Dictionary mediaTags, MediaType dskType) minSpeed = currentSpeed; UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i, (long)totalSize); sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)i, blockSize, 0, @@ -781,7 +781,7 @@ void Xgd(Dictionary mediaTags, MediaType dskType) blocksToRead = (uint)(middleZone - 1 - middle); UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, middle + currentSector, totalSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, middle + currentSector, totalSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)(middle + currentSector), (long)totalSize); mhddLog.Write(middle + currentSector, cmdDuration, blocksToRead); @@ -850,7 +850,7 @@ void Xgd(Dictionary mediaTags, MediaType dskType) minSpeed = currentSpeed; UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, currentSector, totalSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, currentSector, totalSize, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)currentSector, (long)totalSize); sense = _dev.Read12(out readBuffer, out senseBuf, 0, false, false, false, false, (uint)l1, blockSize, 0, @@ -1332,15 +1332,15 @@ void Xgd(Dictionary mediaTags, MediaType dskType) UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds()).Humanize())); if(maxSpeed > 0) UpdateStatus?.Invoke(string.Format(Localization.Core.Fastest_speed_burst_0, - ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond))); + ByteSize.FromMegabytes(maxSpeed).Per(_oneSecond).Humanize())); if(minSpeed is > 0 and < double.MaxValue) UpdateStatus?.Invoke(string.Format(Localization.Core.Slowest_speed_burst_0, - ByteSize.FromMegabytes(minSpeed).Per(_oneSecond))); + ByteSize.FromMegabytes(minSpeed).Per(_oneSecond).Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core._0_sectors_could_not_be_read, _resume.BadBlocks.Count)); UpdateStatus?.Invoke(""); diff --git a/Aaru.Core/Devices/Scanning/ATA.cs b/Aaru.Core/Devices/Scanning/ATA.cs index d932a96e4..ea415d550 100644 --- a/Aaru.Core/Devices/Scanning/ATA.cs +++ b/Aaru.Core/Devices/Scanning/ATA.cs @@ -152,7 +152,7 @@ ScanResults Ata() results.MinSpeed = currentSpeed; UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i, (long)results.Blocks); bool error = ataReader.ReadBlocks(out cmdBuf, i, blocksToRead, out duration, out _, out _); @@ -285,7 +285,8 @@ ScanResults Ata() PulseProgress?.Invoke(string.Format(Localization.Core.Reading_cylinder_0_head_1_sector_2_3, cy, hd, sc, - ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond))); + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond). + Humanize())); bool error = ataReader.ReadChs(out cmdBuf, cy, hd, sc, out duration, out _); diff --git a/Aaru.Core/Devices/Scanning/SCSI.cs b/Aaru.Core/Devices/Scanning/SCSI.cs index 583636abc..c7c50e26e 100644 --- a/Aaru.Core/Devices/Scanning/SCSI.cs +++ b/Aaru.Core/Devices/Scanning/SCSI.cs @@ -364,7 +364,7 @@ ScanResults Scsi() results.MinSpeed = currentSpeed; UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i, (long)results.Blocks); if(readcd) @@ -521,7 +521,7 @@ ScanResults Scsi() results.MinSpeed = currentSpeed; UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks, ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i, (long)results.Blocks); sense = scsiReader.ReadBlocks(out _, i, blocksToRead, out double cmdDuration, out _, out _); diff --git a/Aaru.Core/Devices/Scanning/SecureDigital.cs b/Aaru.Core/Devices/Scanning/SecureDigital.cs index 93d09543a..3c0bd454f 100644 --- a/Aaru.Core/Devices/Scanning/SecureDigital.cs +++ b/Aaru.Core/Devices/Scanning/SecureDigital.cs @@ -245,7 +245,7 @@ ScanResults SecureDigital() results.MinSpeed = currentSpeed; UpdateProgress?. - Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks, ByteSize.FromBytes(currentSpeed).Per(_oneSecond)), + Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, i, results.Blocks, ByteSize.FromBytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i, (long)results.Blocks); bool error; diff --git a/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs b/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs index f35eef814..eb0585022 100644 --- a/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs @@ -48,9 +48,9 @@ using Humanizer.Localisation; using MsBox.Avalonia; using MsBox.Avalonia.Enums; +using ReactiveUI; //using OxyPlot; -using ReactiveUI; namespace Aaru.Gui.ViewModels.Windows; @@ -404,13 +404,13 @@ await Dispatcher.UIThread.InvokeAsync(() => results.ProcessingTime.Seconds().Humanize(minUnit: TimeUnit.Second)); AvgSpeed = string.Format(Localization.Core.Average_speed_0, - ByteSize.FromBytes(results.AvgSpeed).Per(1.Seconds())); + ByteSize.FromBytes(results.AvgSpeed).Per(1.Seconds()).Humanize()); MaxSpeed = string.Format(Localization.Core.Fastest_speed_burst_0, - ByteSize.FromBytes(results.MaxSpeed).Per(1.Seconds())); + ByteSize.FromBytes(results.MaxSpeed).Per(1.Seconds()).Humanize()); MinSpeed = string.Format(Localization.Core.Slowest_speed_burst_0, - ByteSize.FromBytes(results.MinSpeed).Per(1.Seconds())); + ByteSize.FromBytes(results.MinSpeed).Per(1.Seconds()).Humanize()); A = string.Format(Localization.Core._0_sectors_took_less_than_3_ms, results.A); B = string.Format(Localization.Core._0_sectors_took_less_than_10_ms_but_more_than_3_ms, results.B); diff --git a/Aaru/Commands/Media/Scan.cs b/Aaru/Commands/Media/Scan.cs index ef8f538dd..081748eb6 100644 --- a/Aaru/Commands/Media/Scan.cs +++ b/Aaru/Commands/Media/Scan.cs @@ -211,13 +211,14 @@ public static int Invoke(bool debug, bool verbose, string devicePath, string ibg results.TotalTime.Seconds().Humanize(minUnit: TimeUnit.Second), results.ProcessingTime.Seconds().Humanize(minUnit: TimeUnit.Second)); - AaruConsole.WriteLine(Localization.Core.Average_speed_0, ByteSize.FromBytes(results.AvgSpeed).Per(1.Seconds())); + AaruConsole.WriteLine(Localization.Core.Average_speed_0, + ByteSize.FromBytes(results.AvgSpeed).Per(1.Seconds()).Humanize()); AaruConsole.WriteLine(Localization.Core.Fastest_speed_burst_0, - ByteSize.FromBytes(results.MaxSpeed).Per(1.Seconds())); + ByteSize.FromBytes(results.MaxSpeed).Per(1.Seconds()).Humanize()); AaruConsole.WriteLine(Localization.Core.Slowest_speed_burst_0, - ByteSize.FromBytes(results.MinSpeed).Per(1.Seconds())); + ByteSize.FromBytes(results.MinSpeed).Per(1.Seconds()).Humanize()); AaruConsole.WriteLine(); AaruConsole.WriteLine($"[bold]{Localization.Core.Summary}:[/]");