diff options
author | George Hazan <george.hazan@gmail.com> | 2024-01-09 16:25:31 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-01-09 16:25:31 +0300 |
commit | bb9dce4b057d4533f2f8a0c8f5f899790685deff (patch) | |
tree | bcf1e9974508e4547426893b49ff533099d38045 /protocols | |
parent | 43a25d3f11edcc5fbb9dbba1662bbaae92e005ab (diff) |
Jabber: offline file reading switched to Netlib_DownloadFile
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/JabberG/src/jabber_file.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp index 616a629c59..7b0211e70e 100644 --- a/protocols/JabberG/src/jabber_file.cpp +++ b/protocols/JabberG/src/jabber_file.cpp @@ -54,12 +54,13 @@ void __cdecl CJabberProto::OfflineFileThread(OFDTHREAD *ofd) nlhr.m_szUrl = url;
// download the page
- NLHR_PTR nlhrReply(Netlib_HttpTransaction(m_hNetlibUser, &nlhr));
+ NLHR_PTR nlhrReply(encrypted
+ ? Netlib_HttpTransaction(m_hNetlibUser, &nlhr)
+ : Netlib_DownloadFile(m_hNetlibUser, &nlhr, ofd->wszPath));
if (nlhrReply && nlhrReply->resultCode == 200) {
- FILE *f = _wfopen(ofd->wszPath, L"wb");
size_t written = 0;
- if (f) {
- if (encrypted) {
+ if (encrypted) {
+ if (FILE *f = _wfopen(ofd->wszPath, L"wb")) {
int payload_len = nlhrReply->body.GetLength() - 16;
if (payload_len > 0) {
uint8_t ivkey[44];
@@ -80,10 +81,13 @@ void __cdecl CJabberProto::OfflineFileThread(OFDTHREAD *ofd) written = payload_len;
mir_free(out);
}
+ fclose(f);
}
- else if (fwrite(nlhrReply->body, 1, nlhrReply->body.GetLength(), f) == size_t(nlhrReply->body.GetLength()))
- written = nlhrReply->body.GetLength();
- fclose(f);
+ }
+ else {
+ struct _stat st;
+ _wstat(ofd->wszPath, &st);
+ written = st.st_size;
}
if (written) {
|