Repository navigation
Fix large file resume refusing the large_file_sha1 it stored (#223) - #232
Draft
sophiecarreras wants to merge 1 commit into
Draft
sophiecarreras wants to merge 1 commit into
sophiecarreras wants to merge 1 commit into
Conversation
B2LargeFileUploader removed the header form of the key (X-Bz-Info-large_file_sha1) from the stored file info before comparing it with the request's, but the stored key is large_file_sha1. finishUploadingLargeFile therefore threw a local mismatch error for a large file whose content source knows its sha1.
This branch has not been deployed
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.
Fixes #223
Problem
finishUploadingLargeFile(and any other resume of a started large file) threw a localB2LocalExceptionfor a large file whose content source knows its sha1:The request that started the file was refused when it was repeated.
When the content source knows its sha1, the SDK stores it in the large file's file info under the key
large_file_sha1(B2Headers.LARGE_FILE_SHA1_INFO_NAME).B2LargeFileUploader.throwIfLargeFileVersionDoesntSeemToMatchRequestchecks that value as the sha1, and removes it from the stored file info before comparing the rest with the request's file info. It removedB2Headers.LARGE_FILE_SHA1, theX-Bz-Info-large_file_sha1header form, which is not a key of that map, so the entry stayed and was reported as unexpected file info.Fix
Remove
B2Headers.LARGE_FILE_SHA1_INFO_NAMEinstead. Any other file info entry still has to match. Adds a### Fixedentry to the changelog.Tests
In
B2LargeFileUploaderTest:testThrowIfLargeFileVersionDoesntSeemToMatchRequest_matchingSha1IsNotAFileInfoMismatch: a storedlarge_file_sha1equal to the content source's sha1 is accepted. Fails without the fix (throwsB2LocalException), passes with it.testThrowIfLargeFileVersionDoesntSeemToMatchRequest_otherFileInfoStillMismatches: a stored file info entry other thanlarge_file_sha1still causes a mismatch. This passes with and without the fix; it guards against the fix removing more than the one key.I also updated the comment in
.sdkharness/tests/conformance/LargeResume.java, which described the refusal as the current behavior.Verification
./gradlew test(all modules, includescheck_code): build successful, 722 tests, 0 failures, 0 errors.large.resumeconformance check in.sdkharness, run against a local B2 simulator, interrupts a large upload after two parts and then callsfinishUploadingLargeFilewith the same content, with and without a known sha1. On master it fails on the sha1 leg with themismatcherror above; with this change it passes.