Don't re-download the sent text file.

This commit is contained in:
John Preston
2026-04-10 20:59:49 +07:00
parent 05cf8aaa0f
commit 2994268b83
@@ -19,8 +19,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_item.h" #include "history/history_item.h"
#include "history/history.h" #include "history/history.h"
#include "core/file_location.h" #include "core/file_location.h"
#include "core/application.h"
#include "core/mime_type.h" #include "core/mime_type.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "storage/storage_account.h"
#include "apiwrap.h" #include "apiwrap.h"
namespace Storage { namespace Storage {
@@ -331,6 +333,20 @@ void Uploader::upload(
} }
if (!file->filepath.isEmpty()) { if (!file->filepath.isEmpty()) {
document->setLocation(Core::FileLocation(file->filepath)); document->setLocation(Core::FileLocation(file->filepath));
} else if (!file->content.isEmpty()
&& Core::App().canSaveFileWithoutAskingForPath()) {
const auto path = DocumentFileNameForSave(document);
if (!path.isEmpty()) {
auto f = QFile(path);
if (f.open(QIODevice::WriteOnly)
&& f.write(file->content) == file->content.size()) {
f.close();
document->setLocation(Core::FileLocation(path));
session().local().writeFileLocation(
document->mediaKey(),
Core::FileLocation(path));
}
}
} }
if (file->type == SendMediaType::ThemeFile) { if (file->type == SendMediaType::ThemeFile) {
document->checkWallPaperProperties(); document->checkWallPaperProperties();