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

feat(sdk): enable uploading ranges of files in core #7660

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

moredatarequired
Copy link
Contributor

@moredatarequired moredatarequired commented May 17, 2024

Description

Add Offset and Length fields to the filetransfer.Task type, and alter DefaultFileTransfer.Upload so that if those are non-zero only the specified range is uploaded.

This will be used for multipart uploads (draft: #7659).

Question: the Task takes a file path, rather than a file handle. This means that to upload ranges, it needs to open the file (create a file handle) for each range it needs to upload, and large files (>1TB) can be broken up into up to 10,000 pieces. Is this a problem?

  • I updated CHANGELOG.md, or it's not applicable

Testing

Added two small unit tests for functionality.

@moredatarequired moredatarequired requested a review from a team as a code owner May 17, 2024 00:27
Copy link

codecov bot commented May 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.85%. Comparing base (3b16783) to head (3525de7).
Report is 60 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7660      +/-   ##
==========================================
+ Coverage   74.26%   75.85%   +1.58%     
==========================================
  Files         500      500              
  Lines       55656    54061    -1595     
==========================================
- Hits        41334    41007     -327     
+ Misses      13915    12646    -1269     
- Partials      407      408       +1     
Flag Coverage Δ
func 41.49% <ø> (+0.03%) ⬆️
system 63.46% <55.55%> (+0.02%) ⬆️
unit 56.41% <100.00%> (+1.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...ore/internal/filetransfer/file_transfer_default.go 68.80% <100.00%> (+19.98%) ⬆️
core/internal/filetransfer/tasks.go 50.00% <ø> (ø)

... and 102 files with indirect coverage changes

Comment on lines +73 to +81
if task.Offset > 0 || (task.Length > 0 && task.Length < stat.Size()) {
if task.Offset+task.Length > stat.Size() {
ft.logger.Error("file transfer: upload: offset + length is greater than the file size",
"offset", task.Offset, "length", task.Length, "file size", stat.Size())
task.Length = int64(stat.Size() - task.Offset)
}
sectionReader := io.NewSectionReader(file, task.Offset, task.Length)
reader = sectionReader
task.Size = task.Length
Copy link
Contributor

Choose a reason for hiding this comment

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

i think in any case this requires explanation it's not clear why you do the math you do
why it doesn't include the range

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.

None yet

2 participants