Accept only official units.

This commit is contained in:
Michael Lipp 2023-06-11 14:23:53 +02:00
parent 715f97c971
commit 1a454e990a

View file

@ -52,10 +52,10 @@ class Configuration implements Dto {
static {
// SI units and common abbreviations
BigInteger factor = BigInteger.ONE;
unitMap.put("", factor);
BigInteger scale = BigInteger.valueOf(1000);
for (var unit : List.of("B", "kB", "MB", "GB", "TB", "PB", "EB")) {
unitMap.put(unit, factor);
unitMap.put(unit.substring(0, unit.length() - 1), factor);
factor = factor.multiply(scale);
}
// Binary units