Don't autodownload files if sandbox prevents it.

Partially fixes #25308.
This commit is contained in:
John Preston 2022-11-08 18:24:08 +04:00
parent ab5792f59f
commit 092923fe6e
4 changed files with 9 additions and 2 deletions

View File

@ -587,6 +587,12 @@ void Application::saveSettings() {
Local::writeSettings(); Local::writeSettings();
} }
bool Application::canSaveFileWithoutAskingForPath() const {
return !Core::App().settings().askDownloadPath()
&& (!KSandbox::isInside()
|| !Core::App().settings().downloadPath().isEmpty());
}
MTP::Config &Application::fallbackProductionConfig() const { MTP::Config &Application::fallbackProductionConfig() const {
if (!_fallbackProductionConfig) { if (!_fallbackProductionConfig) {
_fallbackProductionConfig = std::make_unique<MTP::Config>( _fallbackProductionConfig = std::make_unique<MTP::Config>(

View File

@ -178,6 +178,7 @@ public:
[[nodiscard]] Settings &settings(); [[nodiscard]] Settings &settings();
void saveSettingsDelayed(crl::time delay = kDefaultSaveDelay); void saveSettingsDelayed(crl::time delay = kDefaultSaveDelay);
void saveSettings(); void saveSettings();
[[nodiscard]] bool canSaveFileWithoutAskingForPath() const;
// Fallback config and proxy. // Fallback config and proxy.
[[nodiscard]] MTP::Config &fallbackProductionConfig() const; [[nodiscard]] MTP::Config &fallbackProductionConfig() const;

View File

@ -1118,7 +1118,7 @@ bool DocumentData::saveFromData() {
bool DocumentData::saveFromDataSilent() { bool DocumentData::saveFromDataSilent() {
return !filepath(true).isEmpty() return !filepath(true).isEmpty()
|| (!Core::App().settings().askDownloadPath() || (Core::App().canSaveFileWithoutAskingForPath()
&& saveFromDataChecked()); && saveFromDataChecked());
} }

View File

@ -291,7 +291,7 @@ void DocumentMedia::automaticLoad(
return; return;
} }
const auto toCache = _owner->saveToCache(); const auto toCache = _owner->saveToCache();
if (!toCache && Core::App().settings().askDownloadPath()) { if (!toCache && !Core::App().canSaveFileWithoutAskingForPath()) {
// We need a filename, but we're supposed to ask user for it. // We need a filename, but we're supposed to ask user for it.
// No automatic download in this case. // No automatic download in this case.
return; return;