2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-30 22:16:14 +00:00

Better check for download path availability in sandbox

This commit is contained in:
Ilya Fedin
2022-11-27 17:16:43 +04:00
committed by John Preston
parent 04a8a9b7ee
commit 54a0f443b4
3 changed files with 39 additions and 6 deletions

View File

@@ -91,6 +91,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/premium_limits_box.h"
#include "ui/boxes/confirm_box.h"
#include <QtCore/QStandardPaths>
#include <QtCore/QMimeDatabase>
#include <QtGui/QGuiApplication>
#include <QtGui/QScreen>
@@ -251,6 +252,15 @@ void Application::run() {
return;
}
if (KSandbox::isInside()) {
const auto path = settings().downloadPath();
if (!path.isEmpty()
&& path != qstr("tmp")
&& !base::CanReadDirectory(path)) {
settings().setDownloadPath(QString());
}
}
_translator = std::make_unique<Lang::Translator>();
QCoreApplication::instance()->installTranslator(_translator.get());
@@ -589,9 +599,15 @@ void Application::saveSettings() {
}
bool Application::canSaveFileWithoutAskingForPath() const {
return !Core::App().settings().askDownloadPath()
&& (!KSandbox::isInside()
|| !Core::App().settings().downloadPath().isEmpty());
if (Core::App().settings().askDownloadPath()) {
return false;
} else if (KSandbox::isInside()
&& Core::App().settings().downloadPath().isEmpty()) {
const auto path = QStandardPaths::writableLocation(
QStandardPaths::DownloadLocation);
return base::CanReadDirectory(path);
}
return true;
}
MTP::Config &Application::fallbackProductionConfig() const {