Skip to content

Commit

Permalink
Fix: use base 2 to calculate filesize
Browse files Browse the repository at this point in the history
Signed-off-by: Daishan Peng <[email protected]>
  • Loading branch information
StrongMonkey authored and cjellick committed Nov 26, 2024
1 parent e38fc09 commit c21c8f1
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions ui/admin/app/components/knowledge/FileTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,14 @@ export default function FileTreeNode({
</div>
<span className="text-xs flex items-center justify-center text-muted-foreground">
{node.file.sizeInBytes
? node.file.sizeInBytes > 1000000
? node.file.sizeInBytes > 1024 * 1024
? (
node.file.sizeInBytes /
1000000
(1024 * 1024)
).toFixed(2) + " MB"
: node.file.sizeInBytes > 1000
: node.file.sizeInBytes > 1024
? (
node.file.sizeInBytes / 1000
node.file.sizeInBytes / 1024
).toFixed(2) + " KB"
: node.file.sizeInBytes + " Bytes"
: "0 Bytes"}
Expand Down Expand Up @@ -455,11 +455,12 @@ export default function FileTreeNode({
</span>
</div>
<div className="whitespace-nowrap text-xs">
{totalSize > 1000000
? (totalSize / 1000000).toFixed(2) +
" MB"
: totalSize > 1000
? (totalSize / 1000).toFixed(2) +
{totalSize > 1024 * 1024
? ((totalSize / 1024) * 1024).toFixed(
2
) + " MB"
: totalSize > 1024
? (totalSize / 1024).toFixed(2) +
" KB"
: totalSize + " Bytes"}
</div>
Expand Down

0 comments on commit c21c8f1

Please sign in to comment.