fix(filesystem): handle negative values in formatSize() (#3231)
Return '0 B' for negative byte values instead of 'NaN B'. File sizes cannot be negative, so this is a safe default. Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
599dafc105
commit
8102fbe27a
1 changed files with 5 additions and 3 deletions
|
|
@ -43,7 +43,7 @@ export interface SearchResult {
|
|||
// Pure Utility Functions
|
||||
export function formatSize(bytes: number): string {
|
||||
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
if (bytes === 0) return '0 B';
|
||||
if (bytes <= 0) return '0 B';
|
||||
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue