Raise file size limit to 2000 MB.

This commit is contained in:
John Preston 2020-07-06 12:18:11 +04:00
parent c9ebe28fc1
commit 2df5972f68
10 changed files with 19 additions and 21 deletions

View file

@ -85,7 +85,6 @@ namespace App {
void setLaunchState(LaunchState state); void setLaunchState(LaunchState state);
void restart(); void restart();
constexpr auto kFileSizeLimit = 1500 * 1024 * 1024; // Load files up to 1500mb
constexpr auto kImageSizeLimit = 64 * 1024 * 1024; // Open images up to 64mb jpg/png/gif constexpr auto kImageSizeLimit = 64 * 1024 * 1024; // Open images up to 64mb jpg/png/gif
QImage readImage(QByteArray data, QByteArray *format = nullptr, bool opaque = true, bool *animated = nullptr); QImage readImage(QByteArray data, QByteArray *format = nullptr, bool opaque = true, bool *animated = nullptr);
QImage readImage(const QString &file, QByteArray *format = nullptr, bool opaque = true, bool *animated = nullptr, QByteArray *content = 0); QImage readImage(const QString &file, QByteArray *format = nullptr, bool opaque = true, bool *animated = nullptr, QByteArray *content = 0);

View file

@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Data { namespace Data {
namespace AutoDownload { namespace AutoDownload {
constexpr auto kMaxBytesLimit = 3000 * 512 * 1024; constexpr auto kMaxBytesLimit = 4000 * 512 * 1024;
enum class Source { enum class Source {
User = 0x00, User = 0x00,

View file

@ -27,7 +27,7 @@ constexpr auto kFileNextRequestDelay = crl::time(20);
constexpr auto kChatsSliceLimit = 100; constexpr auto kChatsSliceLimit = 100;
constexpr auto kMessagesSliceLimit = 100; constexpr auto kMessagesSliceLimit = 100;
constexpr auto kTopPeerSliceLimit = 100; constexpr auto kTopPeerSliceLimit = 100;
constexpr auto kFileMaxSize = 1500 * 1024 * 1024; constexpr auto kFileMaxSize = 2000 * 1024 * 1024;
constexpr auto kLocationCacheSize = 100'000; constexpr auto kLocationCacheSize = 100'000;
struct LocationKey { struct LocationKey {

View file

@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Export { namespace Export {
namespace { namespace {
constexpr auto kMaxFileSize = 1500 * 1024 * 1024; constexpr auto kMaxFileSize = 2000 * 1024 * 1024;
} // namespace } // namespace

View file

@ -88,21 +88,18 @@ int SizeLimitByIndex(int index) {
const auto megabytes = [&] { const auto megabytes = [&] {
if (index <= 10) { if (index <= 10) {
return index; return index;
} } else if (index <= 30) {
else if (index <= 30) {
return 10 + (index - 10) * 2; return 10 + (index - 10) * 2;
} } else if (index <= 40) {
else if (index <= 40) {
return 50 + (index - 30) * 5; return 50 + (index - 30) * 5;
} } else if (index <= 60) {
else if (index <= 60) {
return 100 + (index - 40) * 10; return 100 + (index - 40) * 10;
} } else if (index <= 70) {
else if (index <= 70) {
return 300 + (index - 60) * 20; return 300 + (index - 60) * 20;
} } else if (index <= 80) {
else { return 500 + (index - 70) * 50;
return 500 + (index - 70) * 100; } else {
return 1000 + (index - 80) * 100;
} }
}(); }();
return megabytes * kMegabyte; return megabytes * kMegabyte;

View file

@ -25,7 +25,7 @@ class Session;
namespace Export { namespace Export {
namespace View { namespace View {
constexpr auto kSizeValueCount = 80; constexpr auto kSizeValueCount = 90;
int SizeLimitByIndex(int index); int SizeLimitByIndex(int index);
class SettingsWidget : public Ui::RpWidget { class SettingsWidget : public Ui::RpWidget {

View file

@ -16,7 +16,7 @@ namespace Streaming {
namespace { namespace {
// This is the maximum file size in Telegram API. // This is the maximum file size in Telegram API.
constexpr auto kMaxFileSize = 3000 * 512 * 1024; constexpr auto kMaxFileSize = 4000 * 512 * 1024;
int ValidateLocalSize(int64 size) { int ValidateLocalSize(int64 size) {
return (size > 0 && size <= kMaxFileSize) ? int(size) : 0; return (size > 0 && size <= kMaxFileSize) ? int(size) : 0;

View file

@ -776,7 +776,7 @@ void FileLoadTask::process() {
} }
_result->filesize = (int32)qMin(filesize, qint64(INT_MAX)); _result->filesize = (int32)qMin(filesize, qint64(INT_MAX));
if (!filesize || filesize > App::kFileSizeLimit) { if (!filesize || filesize > kFileSizeLimit) {
return; return;
} }
@ -962,7 +962,7 @@ void FileLoadTask::finish() {
tr::lng_send_image_empty(tr::now, lt_name, _filepath)), tr::lng_send_image_empty(tr::now, lt_name, _filepath)),
Ui::LayerOption::KeepOther); Ui::LayerOption::KeepOther);
removeFromAlbum(); removeFromAlbum();
} else if (_result->filesize > App::kFileSizeLimit) { } else if (_result->filesize > kFileSizeLimit) {
Ui::show( Ui::show(
Box<InformBox>( Box<InformBox>(
tr::lng_send_image_too_large(tr::now, lt_name, _filepath)), tr::lng_send_image_too_large(tr::now, lt_name, _filepath)),

View file

@ -10,6 +10,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/variant.h" #include "base/variant.h"
#include "api/api_common.h" #include "api/api_common.h"
constexpr auto kFileSizeLimit = 2000 * 1024 * 1024; // Load files up to 1500mb
enum class CompressConfirm { enum class CompressConfirm {
Auto, Auto,
Yes, Yes,

View file

@ -190,7 +190,7 @@ MimeDataState ComputeMimeDataState(const QMimeData *data) {
} }
const auto filesize = info.size(); const auto filesize = info.size();
if (filesize > App::kFileSizeLimit) { if (filesize > kFileSizeLimit) {
return MimeDataState::None; return MimeDataState::None;
} else if (allAreSmallImages) { } else if (allAreSmallImages) {
if (filesize > App::kImageSizeLimit) { if (filesize > App::kImageSizeLimit) {
@ -237,7 +237,7 @@ PreparedList PrepareMediaList(const QStringList &files, int previewWidth) {
PreparedList::Error::EmptyFile, PreparedList::Error::EmptyFile,
file file
}; };
} else if (filesize > App::kFileSizeLimit) { } else if (filesize > kFileSizeLimit) {
return { return {
PreparedList::Error::TooLargeFile, PreparedList::Error::TooLargeFile,
file file