mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
Merge pull request #40605 from nextcloud/fix/format-file-sizes
[stable27] Revert change that made `OC.Util.humanFileSize` return decimal sizes instead of binary
This commit is contained in:
commit
049aa5dfde
5 changed files with 12 additions and 14 deletions
|
|
@ -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
|
||||
|
|
@ -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)) {
|
||||
|
|
|
|||
4
dist/core-login.js
vendored
4
dist/core-login.js
vendored
File diff suppressed because one or more lines are too long
2
dist/core-login.js.map
vendored
2
dist/core-login.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/core-main.js
vendored
4
dist/core-main.js
vendored
File diff suppressed because one or more lines are too long
2
dist/core-main.js.map
vendored
2
dist/core-main.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue