From b14bdd865fc362aca106cac9172799134aeaafd4 Mon Sep 17 00:00:00 2001 From: Han Junghyuk <136320007+hanjunghyuk@users.noreply.github.com> Date: Thu, 15 Jun 2023 00:53:32 +0900 Subject: [PATCH] Remove ZB and ZiB from file size type (#9427) # Description This PR removes ZB and ZiB from file size type, as they were showing incorrect values due to an integer overflow. Fixes: #9337 # User-Facing Changes # Tests + Formatting # After Submitting --- crates/nu-command/src/formats/from/nuon.rs | 8 -------- crates/nu-parser/src/parser.rs | 2 -- crates/nu-protocol/src/value/mod.rs | 1 - crates/nu-protocol/src/value/unit.rs | 10 ---------- crates/nu-utils/src/sample_config/default_config.nu | 2 +- 5 files changed, 1 insertion(+), 22 deletions(-) diff --git a/crates/nu-command/src/formats/from/nuon.rs b/crates/nu-command/src/formats/from/nuon.rs index 9a040881b..a06ef338a 100644 --- a/crates/nu-command/src/formats/from/nuon.rs +++ b/crates/nu-command/src/formats/from/nuon.rs @@ -457,10 +457,6 @@ fn convert_to_value( val: size * 1000 * 1000 * 1000 * 1000 * 1000 * 1000, span, }), - Unit::Zettabyte => Ok(Value::Filesize { - val: size * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 * 1000, - span, - }), Unit::Kibibyte => Ok(Value::Filesize { val: size * 1024, @@ -486,10 +482,6 @@ fn convert_to_value( val: size * 1024 * 1024 * 1024 * 1024 * 1024 * 1024, span, }), - Unit::Zebibyte => Ok(Value::Filesize { - val: size * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024, - span, - }), Unit::Nanosecond => Ok(Value::Duration { val: size, span }), Unit::Microsecond => Ok(Value::Duration { diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index 1919d7e80..8dd2333a5 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -2313,14 +2313,12 @@ pub const FILESIZE_UNIT_GROUPS: &[UnitGroup] = &[ (Unit::Terabyte, "TB", Some((Unit::Gigabyte, 1000))), (Unit::Petabyte, "PB", Some((Unit::Terabyte, 1000))), (Unit::Exabyte, "EB", Some((Unit::Petabyte, 1000))), - (Unit::Zettabyte, "ZB", Some((Unit::Exabyte, 1000))), (Unit::Kibibyte, "KIB", Some((Unit::Byte, 1024))), (Unit::Mebibyte, "MIB", Some((Unit::Kibibyte, 1024))), (Unit::Gibibyte, "GIB", Some((Unit::Mebibyte, 1024))), (Unit::Tebibyte, "TIB", Some((Unit::Gibibyte, 1024))), (Unit::Pebibyte, "PIB", Some((Unit::Tebibyte, 1024))), (Unit::Exbibyte, "EIB", Some((Unit::Pebibyte, 1024))), - (Unit::Zebibyte, "ZIB", Some((Unit::Exbibyte, 1024))), (Unit::Byte, "B", None), ]; diff --git a/crates/nu-protocol/src/value/mod.rs b/crates/nu-protocol/src/value/mod.rs index 9916e06c1..5010aef50 100644 --- a/crates/nu-protocol/src/value/mod.rs +++ b/crates/nu-protocol/src/value/mod.rs @@ -3754,7 +3754,6 @@ fn get_filesize_format(format_value: &str, filesize_metric: Option) -> (By "tb" | "tib" => either!(format_value, TB, TiB), "pb" | "pib" => either!(format_value, TB, TiB), "eb" | "eib" => either!(format_value, EB, EiB), - "zb" | "zib" => either!(format_value, ZB, ZiB), _ => (byte_unit::ByteUnit::B, "auto"), } } diff --git a/crates/nu-protocol/src/value/unit.rs b/crates/nu-protocol/src/value/unit.rs index 192d9cba2..31c2c48ab 100644 --- a/crates/nu-protocol/src/value/unit.rs +++ b/crates/nu-protocol/src/value/unit.rs @@ -11,7 +11,6 @@ pub enum Unit { Terabyte, Petabyte, Exabyte, - Zettabyte, // Filesize units: ISO/IEC 80000 Kibibyte, @@ -20,7 +19,6 @@ pub enum Unit { Tebibyte, Pebibyte, Exbibyte, - Zebibyte, // Duration units Nanosecond, @@ -61,10 +59,6 @@ impl Unit { val: size * 1000 * 1000 * 1000 * 1000 * 1000 * 1000, span, }, - Unit::Zettabyte => Value::Filesize { - val: size * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 * 1000, - span, - }, Unit::Kibibyte => Value::Filesize { val: size * 1024, @@ -90,10 +84,6 @@ impl Unit { val: size * 1024 * 1024 * 1024 * 1024 * 1024 * 1024, span, }, - Unit::Zebibyte => Value::Filesize { - val: size * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024, - span, - }, Unit::Nanosecond => Value::Duration { val: size, span }, Unit::Microsecond => Value::Duration { diff --git a/crates/nu-utils/src/sample_config/default_config.nu b/crates/nu-utils/src/sample_config/default_config.nu index ab7653117..523ae3321 100644 --- a/crates/nu-utils/src/sample_config/default_config.nu +++ b/crates/nu-utils/src/sample_config/default_config.nu @@ -283,7 +283,7 @@ let-env config = { } filesize: { metric: true # true => KB, MB, GB (ISO standard), false => KiB, MiB, GiB (Windows standard) - format: "auto" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, zb, zib, auto + format: "auto" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, auto } cursor_shape: { emacs: line # block, underscore, line, blink_block, blink_underscore, blink_line (line is the default)