Add a SHA256 hash checksum attribute to file attachments.

Review Request #14788 — Created Jan. 27, 2026 and updated

Information

Review Board
release-7.1.x

Reviewers

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 the sha256_checksum attribute is accessed.

This also adds a utility function for creating SHA256 hashes, and a
type hint to FileDiff.get_repository() that was useful for this work.

An upcoming change will point FileDiff.patched_sha256 and
FileDiff.orig_sha256 to the corresponding
FileAttachment.sha256_checksum for binary file diffs.

  • Ran unit tests.
  • Used in an upcoming RBTools change where I access the sha256_checksum
    attribute via the API.
Summary ID
Add a SHA256 hash checksum attribute to file attachments.
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 the `sha256_checksum` attribute is accessed. This also adds a utility function for creating SHA256 hashes, and a type hint to `FileDiff.get_repository()` that was useful for this work.
565e3081d48ffc5415436b846bc09959a7f58c02
Checks run (2 succeeded)
flake8 passed.
JSHint passed.