diff options
author | George Hazan <george.hazan@gmail.com> | 2024-01-10 12:11:16 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-01-10 12:11:16 +0300 |
commit | 730c132f369842cd219388905cf981c2e90f98b3 (patch) | |
tree | e347546e613854070cfd3da32eb0e2e8d30b3b91 /protocols/NewsAggregator | |
parent | e688d75e8db7616d7e6d6fb3ed3c892e4fbe8a97 (diff) |
code cleaning
Diffstat (limited to 'protocols/NewsAggregator')
-rw-r--r-- | protocols/NewsAggregator/Src/Utils.cpp | 29 |
1 files changed, 2 insertions, 27 deletions
diff --git a/protocols/NewsAggregator/Src/Utils.cpp b/protocols/NewsAggregator/Src/Utils.cpp index 60aec00266..8c760996aa 100644 --- a/protocols/NewsAggregator/Src/Utils.cpp +++ b/protocols/NewsAggregator/Src/Utils.cpp @@ -212,33 +212,8 @@ bool DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal) nlhr.AddHeader("Cache-Control", "no-cache"); nlhr.AddHeader("Pragma", "no-cache"); - NLHR_PTR pReply(Netlib_HttpTransaction(hNetlibUser, &nlhr)); - if (pReply) { - if (200 == pReply->resultCode && !pReply->body.IsEmpty()) { - const char *date = pReply->FindHeader("Last-Modified"); - const char *size = pReply->FindHeader("Content-Length"); - if (date != nullptr && size != nullptr) { - struct _stat buf; - int fh = _wopen(tszLocal, _O_RDONLY); - if (fh != -1) { - _fstat(fh, &buf); - _close(fh); - - time_t modtime = DateToUnixTime(date, 0); - time_t filemodtime = mktime(localtime(&buf.st_atime)); - if (modtime <= filemodtime || buf.st_size == atoi(size)) - return false; - } - } - - DWORD dwBytes; - HANDLE hFile = CreateFile(tszLocal, GENERIC_READ | GENERIC_WRITE, NULL, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); - WriteFile(hFile, pReply->body, pReply->body.GetLength(), &dwBytes, nullptr); - if (hFile) - CloseHandle(hFile); - } - } - return true; + NLHR_PTR pReply(Netlib_DownloadFile(hNetlibUser, &nlhr, tszLocal)); + return (pReply && 200 == pReply->resultCode); } typedef HRESULT(MarkupCallback)(IHTMLDocument3 *, BSTR &message); |