Skip to content

Set the size of the tftp file before sending#45

Merged
grahamc merged 1 commit intomainfrom
push-xuqnwkwuruyo
Dec 11, 2025
Merged

Set the size of the tftp file before sending#45
grahamc merged 1 commit intomainfrom
push-xuqnwkwuruyo

Conversation

@grahamc
Copy link
Member

@grahamc grahamc commented Dec 10, 2025

Some PXE implementations demand it.

Summary by CodeRabbit

  • Bug Fixes
    • Improved TFTP file transfer handling by ensuring file size is properly communicated during transfers. This addresses potential issues with file transmission reliability and client compatibility.

✏️ Tip: You can customize this high-level summary in your review settings.

Some PXE implementations demand it.
@coderabbitai
Copy link

coderabbitai bot commented Dec 10, 2025

Walkthrough

Added the TFTP v3 library import and integrated a transfer size setting operation in the TFTP read handler. The change calls SetSize() on the outgoing transfer object after initializing the sending state, providing size metadata before data streaming begins.

Changes

Cohort / File(s) Summary
TFTP Transfer Size Metadata
tftp_serve.go
Added github.com/pin/tftp/v3 import; integrated type assertion to invoke SetSize() on outgoing TFTP transfer in tftpReadHandler after state initialization to communicate transfer size before streaming

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Single-file modification with straightforward import addition and one-line functional change
  • Type assertion and method call are minimal, low-risk additions
  • No control flow or architectural modifications

Poem

🐰 A TFTP transfer, now branded with care,
Size metadata set, floating through the air,
One little assertion, precise and aware,
Tells the server exactly what waits to share! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: setting the TFTP file size before sending data, which matches the code modification in tftp_serve.go.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch push-xuqnwkwuruyo

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ad674b5 and ae33f1e.

📒 Files selected for processing (1)
  • tftp_serve.go (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: DeterminateCI / inventory
🔇 Additional comments (1)
tftp_serve.go (1)

11-11: Guard the OutgoingTransfer assertion to avoid panics

rf is declared as io.ReaderFrom, so rf.(tftp.OutgoingTransfer) will panic if this handler is ever invoked with a different implementation (e.g., in tests or after a library change). Use a checked assertion with a fallback to prevent panics while preserving the intended behavior under the normal server.

-	rf.(tftp.OutgoingTransfer).SetSize(underlying_reader.Size())
+	if ot, ok := rf.(tftp.OutgoingTransfer); ok {
+		ot.SetSize(underlying_reader.Size())
+	}

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Member

@RossComputerGuy RossComputerGuy left a comment

Choose a reason for hiding this comment

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

It works so I approve

@grahamc grahamc merged commit de6a3e4 into main Dec 11, 2025
7 checks passed
@grahamc grahamc deleted the push-xuqnwkwuruyo branch December 11, 2025 00:12
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