caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
57.34k stars 4k forks source link

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

Closed francislavoie closed 2 months ago

francislavoie commented 3 months ago

Closes https://github.com/caddyserver/caddy/issues/6409

image

steffenbusch commented 3 months ago

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 commented 3 months ago

You mean calculate both totals? I guess we can.

steffenbusch commented 3 months ago

You mean calculate both totals?

Yes, exaclty.

In modules/caddyhttp/fileserver/browsetplcontext.go, this one was added by me for https://github.com/caddyserver/caddy/issues/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))
}