Point binary file diff's SHA256 hashes to their corresponding file attachment.
Review Request #14792 — Created Jan. 29, 2026 and updated
Filediffs have
patched_sha256andorig_sha256attributes that are
hashes of their patched and original file contents. These get set for
non-binary file diffs the first time that they're loaded into the diff
viewer. Originally, these don't get set for binary file diffs.We recently gave file attachments a
sha256_checksumattribute which
is also a hash of its file contents. For binary file diffs, we can point
to it's corresponding file attachment's hash for both the patched file
and original file. Now, the SHAs will be set for binary file diffs, and
accessible through the file diff_sha256attributes or the file
attachments'sha256_checksum.
- Ran unit tests.
- Accessed the
patched_sha256andorig_sha256attributes for a
binary file diff and saw it was the same as the file attachments'
versions.
| Summary | ID |
|---|---|
| e41e1bff09890e9836339049f2361cb6c0921133 |
-
-
I think this would be clearer if we had more of an if/else structure, since right now it feels like prioritizing the attachment case. We also need to make sure we have an explicit return in all code paths. Something like this?
if not self.binary: return self.extra_data.get('orig_sha256') elif (attachment := FileAttachment.objects.get_for_filediff( self, modified=False)): return attachment.sha256_checksum else: return None -
- Commits:
-
Summary ID 9798bfd77ad01d9ecb8cf13ec5606520d3555f13 4096511ef3fc512c7249aa62b7c625beba9322b6 - Diff:
-
Revision 2 (+38 -4)
Checks run (2 succeeded)
- Commits:
-
Summary ID 4096511ef3fc512c7249aa62b7c625beba9322b6 e41e1bff09890e9836339049f2361cb6c0921133 - Diff:
-
Revision 3 (+52 -4)