Skip to content

fileserver: Exclude symlink target size from total, show arrow on size#6412

Merged
mholt merged 6 commits intomasterfrom
browse-symlink-not-in-total
Jul 7, 2024
Merged

fileserver: Exclude symlink target size from total, show arrow on size#6412
mholt merged 6 commits intomasterfrom
browse-symlink-not-in-total

Conversation

@francislavoie
Copy link
Member

@francislavoie francislavoie commented Jun 19, 2024

Closes #6409

image

@francislavoie francislavoie requested a review from mholt June 19, 2024 22:00
@francislavoie francislavoie added the bug 🐞 Something isn't working label Jun 19, 2024
@steffenbusch
Copy link
Contributor

Can't you at least add a browseTemplateContext method to retrieve the current total size of all files in the listing, so I (sponsor) can at least show what should be shown to my users with my custom browse.html?

@francislavoie
Copy link
Member Author

You mean calculate both totals? I guess we can.

@steffenbusch
Copy link
Contributor

You mean calculate both totals?

Yes, exaclty.

In modules/caddyhttp/fileserver/browsetplcontext.go, this one was added by me for #6002

// HumanTotalFileSize returns the total size of all files
// in the listing as a human-readable string in IEC format
// (i.e. power of 2 or base 1024).
func (btc browseTemplateContext) HumanTotalFileSize() string {
	return humanize.IBytes(uint64(btc.TotalFileSize))
}

@francislavoie francislavoie added this to the v2.8.5 milestone Jun 19, 2024
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I like this idea overall. Thanks for the patch.

Just some questions regarding nuance / implementation.

@mholt mholt merged commit 9338741 into master Jul 7, 2024
@mholt mholt deleted the browse-symlink-not-in-total branch July 7, 2024 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐞 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[file_server] Incorrect file size calculation

4 participants