Skip to content

Commit

Permalink
It works
Browse files Browse the repository at this point in the history
  • Loading branch information
gferon committed Oct 15, 2024
1 parent 26b8930 commit 4b3bacf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
14 changes: 13 additions & 1 deletion libsignal-service/src/push_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ pub trait PushService: MaybeSend {
cdn_id: u32,
resumable_url: &Url,
content_type: &str,
length: usize,
length: u64,
mut headers: HashMap<String, String>,
mut content: R,
) -> Result<AttachmentDigest, ServiceError> {
Expand All @@ -1021,6 +1021,18 @@ pub trait PushService: MaybeSend {
.get_attachment_resume_info_cdn3(resumable_url, headers.clone())
.await?;

if resume_info.content_start == length {
let mut digester =
crate::digeststream::DigestingReader::new(&mut content);
let mut buf = Vec::new();
digester.read_to_end(&mut buf).unwrap();
return Ok(AttachmentDigest {
digest: digester.finalize(),
incremental_digest: None,
incremental_mac_chunk_size: 0,
});
}

let mut digester =
crate::digeststream::DigestingReader::new(&mut content);
digester
Expand Down
8 changes: 4 additions & 4 deletions libsignal-service/src/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ where
attachment_upload_form.cdn,
&resumable_upload_url,
&spec.content_type,
spec.length,
contents.len() as u64,
attachment_upload_form.headers,
&mut std::io::Cursor::new(&contents),
)
Expand Down Expand Up @@ -273,9 +273,9 @@ where
.expect("unix epoch in the past")
.as_millis() as u64,
),
cdn_number: Some(0),
attachment_identifier: Some(AttachmentIdentifier::CdnId(
attachment_upload_form.cdn as u64,
cdn_number: Some(attachment_upload_form.cdn),
attachment_identifier: Some(AttachmentIdentifier::CdnKey(
attachment_upload_form.key,
)),
..Default::default()
})
Expand Down

0 comments on commit 4b3bacf

Please sign in to comment.