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

fix: ensure file transfer service always writes uploaded file #3364

Merged

Conversation

jarhodes314
Copy link
Contributor

Proposed changes

Fixes some flaky tests and a bug in the file transfer service where files were not uploaded in their entirety.

We were previously calling .write, but ignoring the number of bytes written. Since we always want to write the entire chunk, I have replaced this with .write_all. In addition, I've added a BufWriter to improve the performance when writing files, and ensured this buffer is flushed before responding to the request.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue

I've seen multiple failures locally, all of them exhibit the same "empty file" behaviour, and cannot reproduce any tedge-agent failures after applying the fix:

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s)
  • I ran cargo fmt as mentioned in CODING_GUIDELINES
  • I used cargo clippy as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Copy link

codecov bot commented Jan 27, 2025

Codecov Report

Attention: Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../core/tedge_agent/src/http_server/file_transfer.rs 90.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

📢 Thoughts on this report? Let us know!

Copy link
Contributor

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
556 0 2 556 100 1h34m53.377021s

Copy link
Contributor

@albinsuresh albinsuresh left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@didier-wenzek didier-wenzek left a comment

Choose a reason for hiding this comment

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

Approved

@jarhodes314 jarhodes314 added this pull request to the merge queue Jan 28, 2025
Merged via the queue into thin-edge:main with commit e44a0ff Jan 28, 2025
33 checks passed
@reubenmiller reubenmiller added theme:configuration Theme: Configuration management theme:troubleshooting Theme: Troubleshooting and remote control labels Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme:configuration Theme: Configuration management theme:troubleshooting Theme: Troubleshooting and remote control
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants