mirror of https://github.com/borgbase/vorta
Use base 10 to calculate pretty_bytes. Fixes #28
This commit is contained in:
parent
6b25a8d78f
commit
3f7249fb44
|
@ -94,13 +94,13 @@ def pretty_bytes(size):
|
|||
python-format-size-application-converting-b-to-kb-mb-gb-tb/37423778"""
|
||||
if type(size) != int:
|
||||
return ''
|
||||
power = 2**10
|
||||
power = 1000 # GiB is base 2**10, GB is base 10**3.
|
||||
n = 0
|
||||
Dic_powerN = {0: '', 1: 'K', 2: 'M', 3: 'G', 4: 'T'}
|
||||
while size > power:
|
||||
size /= power
|
||||
n += 1
|
||||
return str(round(size))+Dic_powerN[n]+'B'
|
||||
return f'{round(size, 1)} {Dic_powerN[n]}B'
|
||||
|
||||
|
||||
def get_asset(path):
|
||||
|
|
Loading…
Reference in New Issue