diff options
Diffstat (limited to 'protocols/Telegram')
-rw-r--r-- | protocols/Telegram/src/avatars.cpp | 29 | ||||
-rw-r--r-- | 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; |