Allow incremental playback for attachments with plaintextHash

This commit is contained in:
trevor-signal
2026-03-24 17:23:02 -04:00
committed by GitHub
parent c353d41794
commit 3a25597873
2 changed files with 36 additions and 12 deletions

View File

@@ -27,6 +27,7 @@ export function getLocalAttachmentUrl(
AttachmentType,
| 'contentType'
| 'digest'
| 'plaintextHash'
| 'downloadPath'
| 'incrementalMac'
| 'chunkSize'
@@ -87,10 +88,17 @@ export function getLocalAttachmentUrl(
}
url.searchParams.set('key', attachment.key);
if (!attachment.digest) {
throw new Error('getLocalAttachmentUrl: Missing attachment digest!');
// Attachments restored from backup / link & sync may have plaintextHash but not
// digest
if (attachment.plaintextHash) {
url.searchParams.set('plaintextHash', attachment.plaintextHash);
} else if (attachment.digest) {
url.searchParams.set('digest', attachment.digest);
} else {
throw new Error(
'getLocalAttachmentUrl: Missing attachment plaintextHash and digest!'
);
}
url.searchParams.set('digest', attachment.digest);
if (!attachment.incrementalMac) {
throw new Error(