Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Storage Size Display Different from Official Web UI #147

Closed
Blacktea0 opened this issue Oct 6, 2022 · 1 comment
Closed

[BUG] Storage Size Display Different from Official Web UI #147

Blacktea0 opened this issue Oct 6, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@Blacktea0
Copy link

Describe the bug

image

File size displayed in second and third rows different from official version, and it should not display in scientific notation like '1e3'.

How to reproduce

Steps to reproduce the behavior:

  1. Create torrent with file size 1,048,401,181 bytes
  2. Go to "Transfers" page
  3. See error

Expected behavior

It should be same as official.

Official behavior

image

Versions

  • qBittorrent Enhanced Edition v4.4.5.10 Web UI
  • qb-web: latest 79e515a

Additional notes

Maybe file size should round with floor here.

qb-web/src/filters.ts

Lines 5 to 30 in 79e515a

export function toPrecision(value: number, precision: number) {
if (value >= (10 ** precision)) {
return value.toString();
} if (value >= 1) {
return value.toPrecision(precision);
}
return value.toFixed(precision - 1);
}
export function formatSize(value: number): string {
const units = 'KMGTP';
let index = -1;
while (value >= 1000) {
value /= 1024;
index++;
}
const unit = index < 0 ? 'B' : `${units[index]}iB`;
if (index < 0) {
return `${value} ${unit}`;
}
return `${toPrecision(value, 3)} ${unit}`;
}

@Blacktea0 Blacktea0 added the bug Something isn't working label Oct 6, 2022
@CzBiX CzBiX closed this as completed in 21dc76b Oct 7, 2022
@CzBiX
Copy link
Owner

CzBiX commented Oct 7, 2022

Thanks, fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants