Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
Jul 7, 2024

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.

modules/caddyhttp/fileserver/browse.html Outdated Show resolved Hide resolved
modules/caddyhttp/fileserver/browsetplcontext.go Outdated Show resolved Hide resolved
@mholt mholt merged commit 9338741 into master Jul 7, 2024
23 checks passed
@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