-
Notifications
You must be signed in to change notification settings - Fork 484
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
Adding SHA-1 hash validation support. #1140
Conversation
e4212d8
to
a8ba71d
Compare
...ypes-common/src/main/java/org/datatransferproject/types/common/models/photos/PhotoModel.java
Show resolved
Hide resolved
.../src/main/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosInterface.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosInterface.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review! I've updated the commit. Mind having another look?
...ypes-common/src/main/java/org/datatransferproject/types/common/models/photos/PhotoModel.java
Show resolved
Hide resolved
.../src/main/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosInterface.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosInterface.java
Outdated
Show resolved
Hide resolved
e525742
to
6958930
Compare
Added an empty check for the new
Most users seem to like passing empty string in json as well. The |
Added minal change to cast SHA-1 string to upper case so that base16 decoder can decode the SHA1 into bytes.
otherwise we will receive this error if there's any lower case in the SHA-1 string:
|
The Photos upload API can take a SHA-1 hash in the HTTP header. If the hash does not match after the final payload finishes, the API server will return 400 error. This feature is still experimental. It works only for single-payload upload.
Fixed the wrong POST request header builder. (Was using parameter builder instead of header to add the new header.) |
Any hash mismatch will result in the batch import request failure with an UploadErrorException. This matches the current behavior where any network issue will raise an IOExeption and fail the whole batch.
...e/src/main/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosImporter.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosInterface.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosInterface.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosInterface.java
Outdated
Show resolved
Hide resolved
…main/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosInterface.java actually `maybeRethrowFileMismatchError` (and consider moving somewhere common if this isn't specific to Photos APIs)
wrt 0efdfec - whoa sorry about that! I didn't mean to commit onto your branch - I thought I was updating a comment in the Github review flow. Please ignore (feel free to force-push to your own branch as usual!) |
* Migrated from Runners to Extensions (@RunWith -> @ExtendWith) * Migrated @test annotations from Junit 4 -> 5 * Migrated @before & @after to @beforeeach & @AfterEach, @BeforeClass to @BeforeAll Co-authored-by: Ernest Sadykov <[email protected]>
All good! I accepted your change and pushed forward. PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thanks for making the changes; Nothing major in this pass.
...e/src/main/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosImporter.java
Show resolved
Hide resolved
...e/src/main/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosImporter.java
Show resolved
Hide resolved
.../src/main/java/org/datatransferproject/datatransfer/google/photos/GooglePhotosInterface.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please hold off for a moment - I'll get you an alternative PR by end of the day
edit: nevermind
The Photos upload API can take a SHA-1 hash in the HTTP header. If the hash does not match after the final payload finishes, the API server will return 400 error.
This feature is still experimental. It works only for single-payload upload.