Repository navigation
Enhanced transfers part 4: resuming uploads via tus.io protocol - #1303
Merged
Merged
Conversation
| mutex *sync.Mutex | ||
| objects map[string]map[string][]byte | ||
| incomplete map[string]map[string][]byte | ||
| mutex *sync.Mutex |
Contributor
There was a problem hiding this comment.
Why do you need the pointer?
Contributor
Author
There was a problem hiding this comment.
Which pointer? The Mutex is unchanged if that's the one you mean.
Contributor
|
👍 , just some minor comments from me. |
Contributor
Author
|
Tests are currently failing because updating to master has pulled in a flaky test: #1334 |
Contributor
|
Welcome back, @sinbad, and thanks for the speedy fixes. This looks great, and I am really excited to get this into master. 👍 |
chrisd8088
added a commit
to chrisd8088/git-lfs
that referenced
this pull request
Feb 26, 2026
In PR git-lfs#1303 we updated the Git LFS client to support version 1.0 of the "tus" protocol, which allows for HTTP upload requests to be resumed if they are interrupted: https://tus.io/protocols/resumable-upload/1-0-x In the same PR, we also added tests to our shell test suite to verify that the when the "lfs.tusTransfers" configuration option is set to a value considered "true", the Git LFS client will use the "tus" protocol when uploading individual objects over HTTP, and that the client will retry an interrupted request and send the additional data necessary to fully upload an object. These tests are located in the "t/t-resume-tus.sh" script, whose name follows the pattern established in PR git-lfs#1297 when we created the "t/t-resume-http-range.sh" shell script. However, only one of the two tests in the "t/t-resume-tus.sh" script actually checks whether an interrupted object upload request can be resumed with the "tus" protocol. In a previous commit in this PR we moved the tests from the "t/t-resume-http-range.sh" script to a new shell script named "t/t-batch-storage-retries.sh", in order to consolidate all of the tests related to the client's handling of failed or interrupted object transfer HTTP requests, except for those which verify our support of the "tus" protocol. To keep the names of our test scripts as consistent as possible we now rename the "t/t-resume-tus.sh" script to "t/t-batch-storage-upload-tus.sh", which also better reflects the fact that both tests in the "t/t-resume-tus.sh" script validate the client's use of the "tus" protocol for object uploads but only one actually causes a request to be resumed.
chrisd8088
added a commit
to chrisd8088/git-lfs
that referenced
this pull request
Feb 26, 2026
In PR git-lfs#1303 we updated the Git LFS client to support version 1.0 of the "tus" protocol, which allows for HTTP upload requests to be resumed if they are interrupted: https://tus.io/protocols/resumable-upload/1-0-x In the same PR, we also added tests to our shell test suite to verify that the when the "lfs.tusTransfers" configuration option is set to a value considered "true", the Git LFS client will use the "tus" protocol when uploading individual objects over HTTP, and that the client will retry an interrupted request and send the additional data necessary to fully upload an object. (Note that in prior commits in this PR we moved these tests from their previous location in the "t/t-resume-tus.sh" shell script to a new script file named "t/t-batch-storage-upload-tus.sh", and we also renamed the tests to better reflect their purpose.) We now update these tests in several minor respects, and in particular we remove a misleading comment and the related Git LFS object data from the "batch storage HTTP upload retries with tus protocol" test. In that test, which was originally named "tus-upload-interrupted-resume", one comment states that the specific content of a test Git LFS object "announces to server that we want it to abort the download part way, but reject the Range: header and fall back on re-downloading instead". However, the test does not download any objects at all, because the purpose of the test is solely to validate the Git LFS client's support for the "tus" protocol when uploading objects. The comment appears to have been inadvertently copied from a test in another script, likely what is now the "batch storage HTTP download retries after Range header rejected" test in the "t/t-batch-storage-retries.sh" script. (In prior commits in this PR we renamed the test from "resume-http-range-fallback", and moved it from the "t/t-resume-http-range.sh" script to its current location.) In the "batch storage HTTP upload retries with tus protocol" test, the comment regarding downloads and Range headers precedes the creation of a Git LFS object with a long, random string of characters as its content. This adds to the potential confusion which may arise from the comment, since it appears this string may have some special purpose or value. In practice, though, we can replace it with a simple string such as the word "test" without any impact on the test at all, so we do that now. Both tests in the "t/t-batch-storage-upload-tus.sh" script also create objects with the string "send-verify-action" as their content. Unlike the object described above, this string does have a special purpose, in that it causes our "lfstest-gitserver" test utility program to include a verification URL for the object in its JSON response to a Batch API upload request. The Git LFS client will then make a request to this URL after uploading the object, which allows the server to verify that the object has been received and is complete. While our test suite does need to ascertain that the client makes verification URL requests after uploading objects, if a URL is provided for them in a Batch API response, we already do this in the tests in our "t/t-verify.sh" shell script. Therefore we do not actually need to create objects with the "send-verify-action" special content key in the tests of the client's support for the "tus" protocol. Nevertheless, we leave these objects with the "send-verify-action" special content key in place, since the additional checks are still worthwhile. They demonstrate that after uploading an object using the "tus" protocol, the client will contact verification URLs if the server requests them. We do, though, add comments to both tests to clarify the purpose of the special content key and that the additional object verification step is not crucial for the overall correctness of the tests. Next, we reorganize and simplify the tests' other setup actions to match our general idiom for tests of this type. In doing so we update the first test so it creates two objects with the same content as the objects created by the second test. This change simply aligns the actions of tests and makes comparison between them more straightforward. We also expand the comments in both tests regarding the special names of their respective test repositories, since these are recognized by the "lfstest-gitserver" program and cause it to behave in the appropriate manner for each test. In addition to the existing calls to the assert_local_object() assertion function at the end of the tests, we add several grep(1) commands to check for a number of trace log messages and HTTP headers that we expect the final "git lfs push" command to output. To capture the HTTP headers we set the GIT_CURL_VERBOSE environment variable to a value considered "true" before executing the "git lfs push" commands. Note that when accepting object uploads from the "batch storage HTTP upload retries with tus protocol" test, the "lfstest-gitserver" utility will only accept the first third of the object data when the data begins with the first byte of an object. The Git LFS client should then attempt a second pair of HEAD and PATCH requests to upload the remaining data, as per the "tus" protocol. To confirm these subsequent requests are made as we expect, we check for specific trace log messages and HTTP headers with byte offset values calculated by dividing the objects' lengths by three. Those offsets should match the points at which the "lfstest-gitserver" program interrupted the initial upload requests. In both tests, after the "git lfs push" command runs we now also verify that the command succeeded by checking that it returned a zero exit code. Following an idiom we use in many of our shell tests, we check the first element of the PIPESTATUS array variable to determine whether the "git lfs push" command succeeded. (Note that we need to check the PIPESTATUS array variable because the shell's "errexit" attribute ignores the exit codes of all commands in a pipeline other than the final one.) We also adjust the log files captured by the tests to match our standard practice in other similar tests. We now use the simple file name "push.log" for the log files in which we capture the "git lfs push" commands' output. We also remove the redirections and pipelines which generated a log file when running "git commit" and "git lfs track" commands, as we expect these commands to succeed and the test did not check the "commit.log" file at all.
chrisd8088
added a commit
to chrisd8088/git-lfs
that referenced
this pull request
Mar 1, 2026
In PR git-lfs#1303 we updated the Git LFS client to support version 1.0 of the "tus" protocol, which allows for HTTP upload requests to be resumed if they are interrupted: https://tus.io/protocols/resumable-upload/1-0-x In the same PR, we also added tests to our shell test suite to verify that the when the "lfs.tusTransfers" configuration option is set to a value considered "true", the Git LFS client will use the "tus" protocol when uploading individual objects over HTTP, and that the client will retry an interrupted request and send the additional data necessary to fully upload an object. These tests are located in the "t/t-resume-tus.sh" script, whose name follows the pattern established in PR git-lfs#1297 when we created the "t/t-resume-http-range.sh" shell script. However, only one of the two tests in the "t/t-resume-tus.sh" script actually checks whether an interrupted object upload request can be resumed with the "tus" protocol. In a previous commit in this PR we moved the tests from the "t/t-resume-http-range.sh" script to a new shell script named "t/t-batch-storage-retries.sh", in order to consolidate all of the tests related to the client's handling of failed or interrupted object transfer HTTP requests, except for those which verify our support of the "tus" protocol. To keep the names of our test scripts as consistent as possible we now rename the "t/t-resume-tus.sh" script to "t/t-batch-storage-upload-tus.sh", which also better reflects the fact that both tests in the "t/t-resume-tus.sh" script validate the client's use of the "tus" protocol for object uploads but only one actually causes a request to be resumed.
chrisd8088
added a commit
to chrisd8088/git-lfs
that referenced
this pull request
Mar 1, 2026
In PR git-lfs#1303 we updated the Git LFS client to support version 1.0 of the "tus" protocol, which allows for HTTP upload requests to be resumed if they are interrupted: https://tus.io/protocols/resumable-upload/1-0-x In the same PR, we also added tests to our shell test suite to verify that the when the "lfs.tusTransfers" configuration option is set to a value considered "true", the Git LFS client will use the "tus" protocol when uploading individual objects over HTTP, and that the client will retry an interrupted request and send the additional data necessary to fully upload an object. (Note that in prior commits in this PR we moved these tests from their previous location in the "t/t-resume-tus.sh" shell script to a new script file named "t/t-batch-storage-upload-tus.sh", and we also renamed the tests to better reflect their purpose.) We now update these tests in several minor respects, and in particular we remove a misleading comment and the related Git LFS object data from the "batch storage HTTP upload retries with tus protocol" test. In that test, which was originally named "tus-upload-interrupted-resume", one comment states that the specific content of a test Git LFS object "announces to server that we want it to abort the download part way, but reject the Range: header and fall back on re-downloading instead". However, the test does not download any objects at all, because the purpose of the test is solely to validate the Git LFS client's support for the "tus" protocol when uploading objects. The comment appears to have been inadvertently copied from a test in another script, likely what is now the "batch storage HTTP download retries after Range header rejected" test in the "t/t-batch-storage-retries.sh" script. (In prior commits in this PR we renamed the test from "resume-http-range-fallback", and moved it from the "t/t-resume-http-range.sh" script to its current location.) In the "batch storage HTTP upload retries with tus protocol" test, the comment regarding downloads and Range headers precedes the creation of a Git LFS object with a long, random string of characters as its content. This adds to the potential confusion which may arise from the comment, since it appears this string may have some special purpose or value. In practice, though, we can replace it with a simple string such as the word "test" without any impact on the test at all, so we do that now. Both tests in the "t/t-batch-storage-upload-tus.sh" script also create objects with the string "send-verify-action" as their content. Unlike the object described above, this string does have a special purpose, in that it causes our "lfstest-gitserver" test utility program to include a verification URL for the object in its JSON response to a Batch API upload request. The Git LFS client will then make a request to this URL after uploading the object, which allows the server to verify that the object has been received and is complete. While our test suite does need to ascertain that the client makes verification URL requests after uploading objects, if a URL is provided for them in a Batch API response, we already do this in the tests in our "t/t-verify.sh" shell script. Therefore we do not actually need to create objects with the "send-verify-action" special content key in the tests of the client's support for the "tus" protocol. Nevertheless, we leave these objects with the "send-verify-action" special content key in place, since the additional checks are still worthwhile. They demonstrate that after uploading an object using the "tus" protocol, the client will contact verification URLs if the server requests them. We do, though, add comments to both tests to clarify the purpose of the special content key and that the additional object verification step is not crucial for the overall correctness of the tests. Next, we reorganize and simplify the tests' other setup actions to match our general idiom for tests of this type. In doing so we update the first test so it creates two objects with the same content as the objects created by the second test. This change simply aligns the actions of tests and makes comparison between them more straightforward. We also expand the comments in both tests regarding the special names of their respective test repositories, since these are recognized by the "lfstest-gitserver" program and cause it to behave in the appropriate manner for each test. In addition to the existing calls to the assert_local_object() assertion function at the end of the tests, we add several grep(1) commands to check for a number of trace log messages and HTTP headers that we expect the final "git lfs push" command to output. To capture the HTTP headers we set the GIT_CURL_VERBOSE environment variable to a value considered "true" before executing the "git lfs push" commands. Note that when accepting object uploads from the "batch storage HTTP upload retries with tus protocol" test, the "lfstest-gitserver" utility will only accept the first third of the object data when the data begins with the first byte of an object. The Git LFS client should then attempt a second pair of HEAD and PATCH requests to upload the remaining data, as per the "tus" protocol. To confirm these subsequent requests are made as we expect, we check for specific trace log messages and HTTP headers with byte offset values calculated by dividing the objects' lengths by three. Those offsets should match the points at which the "lfstest-gitserver" program interrupted the initial upload requests. In both tests, after the "git lfs push" command runs we now also verify that the command succeeded by checking that it returned a zero exit code. Following an idiom we use in many of our shell tests, we check the first element of the PIPESTATUS array variable to determine whether the "git lfs push" command succeeded. (Note that we need to check the PIPESTATUS array variable because the shell's "errexit" attribute ignores the exit codes of all commands in a pipeline other than the final one.) We also adjust the log files captured by the tests to match our standard practice in other similar tests. We now use the simple file name "push.log" for the log files in which we capture the "git lfs push" commands' output. We also remove the redirections and pipelines which generated a log file when running "git commit" and "git lfs track" commands, as we expect these commands to succeed and the test did not check the "commit.log" file at all.
chrisd8088
added a commit
to chrisd8088/git-lfs
that referenced
this pull request
Apr 1, 2026
In prior commits in this PR we moved all of the tests from our "t/t-resume-http-range.sh" shell script into a new script named "t/t-batch-storage-retries.sh", and also renamed the tests to follow a consistent pattern and better reflect their purpose. We likewise renamed the "t/t-resume-tus.sh" shell script as "t/t-batch-storage-upload-tus.sh" and renamed the tests in that script as well. All these tests begin in part by invoking our clone_repo() test helper function and passing the "reponame" shell variable as both the function's two parameters. However, some of the tests quote the "reponame" variable inconsistently in these calls, a discrepancy which was first introduced with the original versions of the tests in commits c9c457c and c8817ff of PR git-lfs#1297, and in commit 44cf589 of PR git-lfs#1303. As suggested by larsxschneider on PR review, we now add double quotation marks around the "reponame" variable in all of the clone_repo() calls in these functions. Note that there are other instances of this specific inconsistency in other scripts in our test suite, but we leave those to be addressed in a future PR, in order to keep the scope of this PR somewhat constrained. We also take the opportunity to align the indentation of one comment in the "batch storage HTTP download retries with Range header" test to match our standard formatting.
chrisd8088
added a commit
that referenced
this pull request
Jun 2, 2026
In previous commit in this PR we resolved several problems with our legacy test of the Git LFS client's support for HTTP/1.1 chunked transfer encoding during Git LFS object uploads. One of these problems resulted from a mismatch between the name of the repository created by the previous version of the test and the URL path prefix that was expected by the testingChunkedTransferEncoding() function in our "lfstest-gitserver" test utility program. When the "chunked transfer encoding" test was first introduced, it was located in a shell script named "test-chunked-transfer-encoding.sh" in a directory named "test". The test passed the name of its containing script to the basename(1) command and then used the result as the name of the test's primary Git repository. Our "lfstest-gitserver" utility's testingChunkedTransferEncoding() function then checked for a URL path which began with the prefix "/test-chunked-transfer-encoding" in order to match the name of the test's repository. In PR #3125 we renamed the name of our shell test directory from "test" to "t", and in commit 219b7e0 of that PR we renamed all our shell test scripts to begin with "t-" rather than "test-". An unintended consequence of this change, though, was that the testingChunkedTransferEncoding() function would no longer recognize the repository name from the "chunked transfer encoding" test. Due to the design of the shell test, it continued to pass, but without exercising the behaviour of the Git LFS client it was intended to verify. Fortunately, the legacy "chunked transfer encoding" test was the only test affected in this way by the shell script name changes from PR #3125. While the "lfstest-gitserver" utility at that point had several functions similar to the testingChunkedTransferEncoding() function, each of which checked for a specific repository name prefix in the URL path of a request, the tests which relied on these functions to recognize their repositories all used fixed names for their repositories rather than deriving them from the names of the enclosing scripts. To help resolve the problems with the "chunked transfer encoding" test, we replaced it with a new "batch storage HTTP upload with chunked transfer encoding" test in our "t/t-batch-storage-encoding.sh" script. This test uses a fixed name for its repository rather than one dynamically determined from the name of the containing script. We then updated the testingChunkedTransferEncoding() function in our server utility to check that the current request's repository name exactly matched that fixed string. We also revised the testingChunkedTransferEncoding() function so that its sole parameter is a repository name string rather than a Request structure from the Go standard library's "http" package. This change resolved another problem with the legacy "chunked transfer encoding" test that was due to the fact that the URL paths of requests to upload individual Git LFS objects do not begin with the repository name as an initial path component, and the original test's implementation did not take account of this. Although the testingChunkedTransferEncoding() function was called while handling an object upload, it could only ever return "false" in this case because the URL path would never begin with a repository name. There are three other functions in our "lfstest-gitserver" utility which were all modelled on the testingChunkedTransferEncoding() function, and as such all check the URL path of a Request structure against a specific prefix. These functions are named testingTusUploadInBatchReq(), testingTusUploadInterruptedInBatchReq(), and testingCustomTransfer(). As we would like to reduce the chance that we might in the future accidentally introduce problems similar to those we found with the "chunked transfer encoding" test, we now revise these three functions so their input parameters are repository names rather than Request structures. The functions are all called from the lfsBatchHandler() function of the server utility, which has already extracted a repository name from the initial path component of the current request, so in each case we can just pass the "repo" variable to the three functions. We also update the repository names used by the associated shell tests to eliminate the legacy "test-" prefix and to align the repository names more closely with the names of the tests as they presently exist. For instance, since PR #6207 the tests which rely on the testingTusUploadInBatchReq() function and the testingTusUploadInterruptedInBatchReq() function are now in the "t/t-batch-storage-upload-tus.sh" script, but were originally introduced in a "test/test-resume-tus.sh" script in PR #1303. Meanwhile, the tests which rely on the testingCustomTransfer() function are now in the "t/t-custom-transfers.sh" script but were first introduced in a "test/test-custom-transfers.sh" script in PR #1367. Finally, we update the testingTusUploadInterruptedInBatchReq() function so it performs a more constrained check of the given repository name, as it only needs to return "true" if the name exactly matches the string "batch-storage-upload-tus-interrupt".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new "tus" transfer adapter which uses the tus.io resumable upload protocol (HEAD/PATCH methods). This allows a server to share upload action links to an endpoint which supports this protocol and therefore allow upload resuming.
The included tests implement the server protocol too to prove it works, and I'm also submitting a PR to lfs-test-server which uses the official
tusdserver to prove it works using the official implementation and to demonstrate how you might go about using it.