From 4d82837e0d2c2eb398414ed58ce9fafb15304362 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 25 Nov 2024 13:32:42 +0300 Subject: =?UTF-8?q?fixes=20#4663=20(Telegram:=20=D0=BD=D0=B5=D0=BA=D0=BE?= =?UTF-8?q?=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=BD=D0=BE=20=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=B0=D0=B5=D1=82=20=D0=BE=D1=82=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=BD=D0=B5=D1=81=D0=BA=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=BA=D0=B8=D1=85=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Telegram/src/avatars.cpp | 29 +++++++++++++++-------------- protocols/Telegram/src/proto.cpp | 5 +---- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/protocols/Telegram/src/avatars.cpp b/protocols/Telegram/src/avatars.cpp index 0636af1f04..96e861419b 100644 --- a/protocols/Telegram/src/avatars.cpp +++ b/protocols/Telegram/src/avatars.cpp @@ -221,22 +221,27 @@ void CTelegramProto::ProcessFile(TD::updateFile *pObj) if (pFile == nullptr) return; + auto *pLocal = pFile->local_.get(); auto *pRemote = pFile->remote_.get(); if (pRemote == nullptr) return; - if (!pFile->local_->is_downloading_completed_) { + if (!pLocal->is_downloading_completed_) { if (auto *F = FindFile(pRemote->unique_id_.c_str())) { if (F->m_type != F->AVATAR && F->ofd) { DBVARIANT dbv = { DBVT_DWORD }; - dbv.dVal = pFile->local_->downloaded_size_; + dbv.dVal = pLocal->downloaded_size_; db_event_setJson(F->ofd->hDbEvent, "ft", &dbv); } } return; } - Utf2T wszExistingFile(pFile->local_->path_.c_str()); + // file upload is not completed, skip it + if (pRemote->is_uploading_active_) + return; + + Utf2T wszExistingFile(pLocal->path_.c_str()); if (auto *F = FindFile(pRemote->unique_id_.c_str())) { if (F->m_type == F->AVATAR) { @@ -267,25 +272,21 @@ void CTelegramProto::ProcessFile(TD::updateFile *pObj) SmileyAdd_LoadContactSmileys(SMADD_FILE, m_szModuleName, wszFullName); else NS_NotifyFileReady(wszFullName); - - mir_cslock lck(m_csFiles); - m_arFiles.remove(F); - delete F; } else { // FILE, PICTURE, VIDEO, VOICE if (F->ofd == nullptr) return; DBVARIANT dbv = { DBVT_DWORD }; - dbv.dVal = pFile->local_->downloaded_size_; + dbv.dVal = pLocal->downloaded_size_; db_event_setJson(F->ofd->hDbEvent, "ft", &dbv); CMStringW wszFullName(F->ofd->wszPath); int idxSlash = wszFullName.ReverseFind('\\') + 1; if (wszFullName.Find('.', idxSlash) == -1) { - auto *pSlash = strrchr(pFile->local_->path_.c_str(), '\\'); + auto *pSlash = strrchr(pLocal->path_.c_str(), '\\'); if (!pSlash) - pSlash = pFile->local_->path_.c_str(); + pSlash = pLocal->path_.c_str(); else pSlash++; @@ -310,11 +311,11 @@ void CTelegramProto::ProcessFile(TD::updateFile *pObj) MoveFileW(wszExistingFile, F->ofd->wszPath); F->ofd->Finish(); - - mir_cslock lck(m_csFiles); - m_arFiles.remove(F); - delete F; } + + mir_cslock lck(m_csFiles); + m_arFiles.remove(F); + delete F; return; } diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp index a61d72b6ba..efb92742fb 100644 --- a/protocols/Telegram/src/proto.cpp +++ b/protocols/Telegram/src/proto.cpp @@ -458,9 +458,6 @@ void CTelegramProto::ProcessFileMessage(TG_FILE_REQUEST *ft, const TD::message * szUserId[0] = 0; if (bCreateEvent) { - auto *pFileName = pFile->local_->path_.c_str(); - CMStringA szDescr = GetMessageText(pUser, pMsg); - DB::EventInfo dbei; dbei.szModule = Proto_GetBaseAccountName(ft->m_hContact); dbei.eventType = EVENTTYPE_FILE; @@ -468,7 +465,7 @@ void CTelegramProto::ProcessFileMessage(TG_FILE_REQUEST *ft, const TD::message * dbei.timestamp = time(0); TG_FILE_REQUEST localft(TG_FILE_REQUEST::FILE, 0, 0); - localft.m_fileName = Utf2T(pFileName); + localft.m_fileName = Utf2T(pFile->local_->path_.c_str()); localft.m_fileSize = pFile->size_; localft.m_uniqueId = szMsgId; localft.m_szUserId = szUserId; -- cgit v1.2.3