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

[stable27] Revert change that made OC.Util.humanFileSize return decimal sizes instead of binary #40605

Merged
merged 2 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions core/src/OC/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ export default {
History,

/**
* @deprecated use https://nextcloud.github.io/nextcloud-files/functions/formatFileSize.html
* @param {number} size Size in bytes
* @param {boolean} skipSmallSizes return '< 1 KiB' for small files
* @deprecated use `@nextcloud/files`, see https://nextcloud-libraries.github.io/nextcloud-files/functions/formatFileSize.html
*/
humanFileSize,
humanFileSize: (size, skipSmallSizes) => humanFileSize(size, skipSmallSizes, true).replace('iB', 'B'), // the replace is for backwards compatibility, where binary sizes but decimal units were used

/**
* Returns a file size in bytes from a humanly readable string
Expand All @@ -87,20 +89,16 @@ export default {
let bytes = null

const bytesArray = {
'': 1,
b: 1,
k: 1024,
kb: 1024,
mb: 1024 * 1024,
m: 1024 * 1024,
gb: 1024 * 1024 * 1024,
g: 1024 * 1024 * 1024,
tb: 1024 * 1024 * 1024 * 1024,
t: 1024 * 1024 * 1024 * 1024,
pb: 1024 * 1024 * 1024 * 1024 * 1024,
p: 1024 * 1024 * 1024 * 1024 * 1024,
}

const matches = s.match(/^[\s+]?([0-9]*)(\.([0-9]+))?( +)?([kmgtp]?b?)$/i)
const matches = s.match(/^[\s+]?([0-9]*)(\.([0-9]+))?( +)?([kmgtp]?)i?b?$/i)
if (matches !== null) {
bytes = parseFloat(s)
if (!isFinite(bytes)) {
Expand Down
4 changes: 2 additions & 2 deletions dist/core-login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-login.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-main.js.map

Large diffs are not rendered by default.