From 4acc1beaf4464f4fc3db10cc4b865a0192fb4fa3 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Fri, 26 Apr 2024 03:18:47 +0100 Subject: [PATCH] [UI] Fix speed values humanization. --- Aaru.Core/Devices/Dumping/ATA.cs | 15 +++++++---- Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs | 26 +++++++++++-------- .../Devices/Dumping/LinearMemory/Retrode.cs | 6 +++-- Aaru.Core/Devices/Dumping/MiniDisc.cs | 15 +++++++---- .../PlayStationPortable/MemoryStick.cs | 15 +++++++---- .../Dumping/PlayStationPortable/UMD.cs | 12 ++++++--- Aaru.Core/Devices/Dumping/SSC.cs | 15 +++++++---- Aaru.Core/Devices/Dumping/Sbc/Dump.cs | 18 ++++++++----- Aaru.Core/Devices/Dumping/SecureDigital.cs | 15 +++++++---- Aaru.Core/Devices/Dumping/XGD.cs | 12 ++++++--- Aaru.Core/ImageInfo.cs | 3 ++- .../ViewModels/Panels/ImageInfoViewModel.cs | 3 ++- 12 files changed, 101 insertions(+), 54 deletions(-) diff --git a/Aaru.Core/Devices/Dumping/ATA.cs b/Aaru.Core/Devices/Dumping/ATA.cs index 15ea0fd19..8e0a00e02 100644 --- a/Aaru.Core/Devices/Dumping/ATA.cs +++ b/Aaru.Core/Devices/Dumping/ATA.cs @@ -390,11 +390,13 @@ public partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds()). + Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()))); + Per(imageWriteDuration.Seconds()). + Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); @@ -671,11 +673,13 @@ public partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds()). + Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()))); + Per(imageWriteDuration.Seconds()). + Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); @@ -880,7 +884,8 @@ public partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds()))); + Per(totalChkDuration.Milliseconds()). + Humanize())); _dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)); diff --git a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs index facf19d55..07d2a37a7 100644 --- a/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs +++ b/Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs @@ -1307,23 +1307,27 @@ sealed partial class Dump _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()))); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(string.Format(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()))); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(imageWriteDuration.Seconds()) + .Humanize())); TrimCdUserData(audioExtents, blockSize, currentTry, extents, newTrim, offsetBytes, read6, read10, read12, read16, readcd, sectorsForOffset, subSize, supportedSubchannel, supportsLongSectors, @@ -1489,9 +1493,9 @@ sealed partial class Dump _imageCloseStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0, - ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()). - Humanize())); + ByteSize.FromBytes(blockSize * (blocks + 1)) + .Per(totalDuration.Milliseconds()) + .Humanize())); if(maxSpeed > 0) { diff --git a/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs b/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs index 180227792..b2b74e0b8 100644 --- a/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs +++ b/Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs @@ -372,11 +372,13 @@ public partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, ByteSize.FromBytes(512 * (romSectors + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds()). + Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0, ByteSize.FromBytes(512 * (romSectors + 1)). - Per(imageWriteDuration.Seconds()))); + Per(imageWriteDuration.Seconds()). + Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); diff --git a/Aaru.Core/Devices/Dumping/MiniDisc.cs b/Aaru.Core/Devices/Dumping/MiniDisc.cs index c07a2e93c..9b217918f 100644 --- a/Aaru.Core/Devices/Dumping/MiniDisc.cs +++ b/Aaru.Core/Devices/Dumping/MiniDisc.cs @@ -447,22 +447,26 @@ partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds()). + Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()))); + Per(imageWriteDuration.Seconds()). + Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + 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 @@ -786,7 +790,8 @@ partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds()))); + Per(totalChkDuration.Milliseconds()). + Humanize())); _dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)); diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs index 83de8dc57..250f069a3 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/MemoryStick.cs @@ -285,22 +285,26 @@ public partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds()). + Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()))); + Per(imageWriteDuration.Seconds()). + Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + 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 @@ -645,7 +649,8 @@ public partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds()))); + Per(totalChkDuration.Milliseconds()). + Humanize())); _dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)); diff --git a/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs b/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs index cfbce3822..6155129ba 100644 --- a/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs +++ b/Aaru.Core/Devices/Dumping/PlayStationPortable/UMD.cs @@ -306,22 +306,26 @@ public partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds()). + Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()))); + Per(imageWriteDuration.Seconds()). + Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + 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 diff --git a/Aaru.Core/Devices/Dumping/SSC.cs b/Aaru.Core/Devices/Dumping/SSC.cs index 7eedaa4e2..76da1c6e9 100644 --- a/Aaru.Core/Devices/Dumping/SSC.cs +++ b/Aaru.Core/Devices/Dumping/SSC.cs @@ -1128,22 +1128,26 @@ partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds()). + Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()))); + Per(imageWriteDuration.Seconds()). + Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + 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 Error handling @@ -1408,7 +1412,8 @@ partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds()))); + Per(totalChkDuration.Milliseconds()). + Humanize())); _dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)); diff --git a/Aaru.Core/Devices/Dumping/Sbc/Dump.cs b/Aaru.Core/Devices/Dumping/Sbc/Dump.cs index d577bb234..1cf68d6a5 100644 --- a/Aaru.Core/Devices/Dumping/Sbc/Dump.cs +++ b/Aaru.Core/Devices/Dumping/Sbc/Dump.cs @@ -802,22 +802,26 @@ partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds()). + Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()))); + Per(imageWriteDuration.Seconds()). + Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + 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 @@ -1114,14 +1118,16 @@ partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds()))); + Per(totalChkDuration.Milliseconds()). + Humanize())); _dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)); _dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds())); + Per(totalChkDuration.Milliseconds()). + Humanize()); if(_preSidecar != null) { diff --git a/Aaru.Core/Devices/Dumping/SecureDigital.cs b/Aaru.Core/Devices/Dumping/SecureDigital.cs index a929d2830..85bc6611b 100644 --- a/Aaru.Core/Devices/Dumping/SecureDigital.cs +++ b/Aaru.Core/Devices/Dumping/SecureDigital.cs @@ -731,22 +731,26 @@ public partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds()). + Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()))); + Per(imageWriteDuration.Seconds()). + Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds()). + Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()))); + Per(imageWriteDuration.Seconds()). + Humanize())); #region Trimming @@ -951,7 +955,8 @@ public partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalChkDuration.Milliseconds()))); + Per(totalChkDuration.Milliseconds()). + Humanize())); _dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, _sidecarStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second)); diff --git a/Aaru.Core/Devices/Dumping/XGD.cs b/Aaru.Core/Devices/Dumping/XGD.cs index 37cb4d9ef..3072c55b5 100644 --- a/Aaru.Core/Devices/Dumping/XGD.cs +++ b/Aaru.Core/Devices/Dumping/XGD.cs @@ -967,22 +967,26 @@ partial class Dump UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + Per(totalDuration.Milliseconds()). + Humanize())); UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(imageWriteDuration.Seconds()))); + Per(imageWriteDuration.Seconds()). + Humanize())); _dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, _dumpStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second))); _dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0, ByteSize.FromBytes(blockSize * (blocks + 1)). - Per(totalDuration.Milliseconds()))); + 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 diff --git a/Aaru.Core/ImageInfo.cs b/Aaru.Core/ImageInfo.cs index f651efee8..18b77738a 100644 --- a/Aaru.Core/ImageInfo.cs +++ b/Aaru.Core/ImageInfo.cs @@ -50,6 +50,7 @@ using Aaru.Decoders.PCMCIA; using Aaru.Decoders.SCSI; using Aaru.Decoders.Xbox; using Aaru.Helpers; +using Humanizer; using Humanizer.Bytes; using Spectre.Console; using DDS = Aaru.Decoders.DVD.DDS; @@ -99,7 +100,7 @@ public static class ImageInfo AaruConsole.WriteLine(Localization.Core.Contains_a_media_of_0_sectors_with_a_maximum_sector_size_of_1_bytes_etc, imageFormat.Info.Sectors, imageFormat.Info.SectorSize, - ByteSize.FromBytes(imageFormat.Info.Sectors * imageFormat.Info.SectorSize)); + ByteSize.FromBytes(imageFormat.Info.Sectors * imageFormat.Info.SectorSize).Humanize()); if(!string.IsNullOrWhiteSpace(imageFormat.Info.Creator)) AaruConsole.WriteLine(Localization.Core.Created_by_0_WithMarkup, Markup.Escape(imageFormat.Info.Creator)); diff --git a/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs b/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs index e2ee2a29c..2b08ec239 100644 --- a/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs @@ -53,6 +53,7 @@ using Aaru.Localization; using Avalonia.Controls; using Avalonia.Media.Imaging; using Avalonia.Platform; +using Humanizer; using Humanizer.Bytes; using ReactiveUI; using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry; @@ -129,7 +130,7 @@ public sealed class ImageInfoViewModel : ViewModelBase SectorsText = string.Format(Localization.Core.Contains_a_media_of_0_sectors_with_a_maximum_sector_size_of_1_bytes_etc, imageFormat.Info.Sectors, imageFormat.Info.SectorSize, - ByteSize.FromBytes(imageFormat.Info.Sectors * imageFormat.Info.SectorSize)); + ByteSize.FromBytes(imageFormat.Info.Sectors * imageFormat.Info.SectorSize).Humanize()); MediaTypeText = string.Format(Localization.Core.Contains_a_media_of_type_0_and_XML_type_1, imageFormat.Info.MediaType, imageFormat.Info.MetadataMediaType);