Skip to content

Show filesize - #40

Merged
adixon merged 3 commits into
adixon:masterfrom
gngn23:show_filesize
May 15, 2026
Merged

Show filesize#40
adixon merged 3 commits into
adixon:masterfrom
gngn23:show_filesize

Conversation

@gngn23

@gngn23 gngn23 commented Apr 2, 2026

Copy link
Copy Markdown

No description provided.

@gngn23

gngn23 commented Apr 2, 2026

Copy link
Copy Markdown
Author

Show file size, as discussed in #26

@gngn23 gngn23 mentioned this pull request Apr 2, 2026
@gngn23

gngn23 commented Apr 2, 2026

Copy link
Copy Markdown
Author

I also added some basic error check in case filesize() returns FALSE.

@gngn23

gngn23 commented May 6, 2026

Copy link
Copy Markdown
Author

@adixon can I do anything about this ticket?

@adixon

adixon commented May 6, 2026

Copy link
Copy Markdown
Owner

@adixon can I do anything about this ticket?

Yes, there's a comment in there, I think you're running the risk of trying to evaluate log(0), which isn't pretty.

@gngn23

gngn23 commented May 14, 2026

Copy link
Copy Markdown
Author

I do not see a comment, but I think you mean

  protected function readableBytes(int|string $bytes): string {
    $i = floor(log($bytes) / log(1024));
    $sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
    return sprintf('%.02F', $bytes / pow(1024, $i)) * 1 . ' ' . $sizes[$i];

And you're right, I should check if $bytes is 0.

I am going to fix this.

@gngn23

gngn23 commented May 15, 2026

Copy link
Copy Markdown
Author

@adixon : I am now checking zero or negative number of bytes.
I also changed function readableBytes() to only accept int (and fixed an unrelated typo).

What do you think?

@adixon
adixon merged commit 45b702f into adixon:master May 15, 2026
@adixon

adixon commented May 15, 2026

Copy link
Copy Markdown
Owner

That works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants