Add a SHA256 hash checksum attribute to file attachments.
Review Request #14788 — Created Jan. 27, 2026 and updated — Latest diff uploaded
This adds
FileAttachment.sha256_checksum, a SHA256 file content hash
of a file. We expose this attribute via the API so that callers can use
it to checksum file attachments. We generate and set this hash in our
upload file form, and in another spot where we create a file attachment for
the original version of binary files in the diff viewer. Even if these
two points don't cover all file attachment creation cases, the hash gets
set on demand whenever thesha256_checksumattribute is accessed.This also adds a utility function for creating SHA256 hashes, and a
type hint toFileDiff.get_repository()that was useful for this work.An upcoming change will point
FileDiff.patched_sha256and
FileDiff.orig_sha256to the corresponding
FileAttachment.sha256_checksumfor binary file diffs.
- Ran unit tests.
- Used in an upcoming RBTools change where I access the
sha256_checksum
attribute via the API.