Skip to content

fileserver: handle empty files in size try policies - #8322

Merged
steadytao merged 2 commits into
caddyserver:masterfrom
BenMacha:fix-try-policy-empty-files
Nov 3, 2026
Merged

steadytao merged 2 commits into
caddyserver:masterfrom
BenMacha:fix-try-policy-empty-files

Conversation

@BenMacha

@BenMacha BenMacha commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Use the chosen file info, not a zero size, to tell whether a candidate
was chosen, so smallest_size keeps an empty file and largest_size can
choose one.

Behaviour change: largest_size now matches when every existing candidate is empty, where it used to match nothing.

Assistance Disclosure

The bug was found during a code review done with Claude Code (Anthropic), which also drafted the fix and the test. I reviewed the change, can explain every line, and ran go test -race -short on the affected package before opening this PR.

Use the chosen file info, not a zero size, to tell whether a candidate
was chosen, so smallest_size keeps an empty file and largest_size can
choose one.
@caddy-cla

caddy-cla Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

✅ Contributor License Agreement

All identified contributors have signed the CLA. Thank you!

@steadytao steadytao added the bug 🐞 Something isn't working label Nov 3, 2026
@steadytao steadytao added this to the v2.12.0 milestone Nov 3, 2026
@steadytao
steadytao enabled auto-merge (squash) November 3, 2026 06:51
@steadytao
steadytao merged commit cce035d into caddyserver:master Nov 3, 2026
27 checks passed
This was referenced Nov 3, 2026
NickCao pushed a commit to NickCao/caddy that referenced this pull request Nov 4, 2026
Use the chosen file info, not a zero size, to tell whether a candidate
was chosen, so smallest_size keeps an empty file and largest_size can
choose one.

(cherry picked from commit cce035d)
@francislavoie francislavoie modified the milestones: v2.12.0, v2.11.8 Nov 4, 2026
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.

3 participants