Merge pull request #32639 from overleaf/fix/figure-modal-zero-byte-file-crash
[web] Fix FileSize crash when uploading zero-byte file in figure modal GitOrigin-RevId: 6ce0dfa221c44af4df813231c97aac846214b34d
This commit is contained in:
committed by
Copybot
parent
65ba7c8dd4
commit
e4b49b00ec
+4
-4
@@ -331,10 +331,10 @@ const FileSize: FC<{ size: number; className?: string }> = ({
|
||||
['TB', 1e12],
|
||||
['PB', 1e15],
|
||||
]
|
||||
const labelIndex = Math.min(
|
||||
Math.floor(Math.log10(size) / 3),
|
||||
BYTE_UNITS.length - 1
|
||||
)
|
||||
const labelIndex =
|
||||
size > 0
|
||||
? Math.min(Math.floor(Math.log10(size) / 3), BYTE_UNITS.length - 1)
|
||||
: 0
|
||||
|
||||
const [label, bytesPerUnit] = BYTE_UNITS[labelIndex]
|
||||
const sizeInUnits = Math.round(size / bytesPerUnit)
|
||||
|
||||
Reference in New Issue
Block a user