b2-sdk-python icon indicating copy to clipboard operation
b2-sdk-python copied to clipboard

If content SHA1 is provided, populate it in file info as large_file_sha1 for large files

Open sTywin opened this issue 5 years ago • 0 comments

B2 does not provide the contentSha1 value for large files, instead returning "none". This can cause confusion for many users [1], and the fact that the B2 CLI does not populate the large_file_sha1 file info entry is arguably a bug.

This implementation only adds the large_file_sha1 file info entry if it is not already present, and the content SHA1 is known in advance (i.e. it will not cause a SHA1 to be computed if it is not provided). This works with B2 CLI when specifying the "--sha1" option, which without this, would silently swallow the provided SHA1, which the user would likely not notice until after the potentially lengthy upload was complete.

In addition, this implementation only applies for emerge, not emerge_stream, since it's not clear to me where the known SHA1 would be, assuming it were provided.

[1] https://github.com/Backblaze/B2_Command_Line_Tool/issues/604

sTywin avatar Jan 10 '21 20:01 sTywin