mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-08 08:04:08 +02:00
Use QStandardPaths to find the externalupdater config
That should be more convenient for everyone and cross-platform...
This commit is contained in:
parent
7b4a542890
commit
27b443b24d
1 changed files with 21 additions and 10 deletions
|
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/options.h"
|
#include "base/options.h"
|
||||||
|
|
||||||
#include <QtCore/QLoggingCategory>
|
#include <QtCore/QLoggingCategory>
|
||||||
|
#include <QtCore/QStandardPaths>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -115,16 +116,26 @@ void ComputeDebugMode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComputeExternalUpdater() {
|
void ComputeExternalUpdater() {
|
||||||
QFile file(u"/etc/tdesktop/externalupdater"_q);
|
auto locations = QStandardPaths::standardLocations(
|
||||||
|
QStandardPaths::AppDataLocation);
|
||||||
if (file.exists() && file.open(QIODevice::ReadOnly)) {
|
if (locations.isEmpty()) {
|
||||||
QTextStream fileStream(&file);
|
locations << QString();
|
||||||
while (!fileStream.atEnd()) {
|
}
|
||||||
const auto path = fileStream.readLine();
|
locations[0] = QDir::cleanPath(cWorkingDir());
|
||||||
|
locations << QDir::cleanPath(cExeDir());
|
||||||
if (path == (cExeDir() + cExeName())) {
|
for (const auto &location : locations) {
|
||||||
SetUpdaterDisabledAtStartup();
|
const auto dir = location + u"/externalupdater.d"_q;
|
||||||
return;
|
for (const auto &info : QDir(dir).entryInfoList(QDir::Files)) {
|
||||||
|
QFile file(info.absoluteFilePath());
|
||||||
|
if (file.open(QIODevice::ReadOnly)) {
|
||||||
|
QTextStream fileStream(&file);
|
||||||
|
while (!fileStream.atEnd()) {
|
||||||
|
const auto path = fileStream.readLine();
|
||||||
|
if (path == (cExeDir() + cExeName())) {
|
||||||
|
SetUpdaterDisabledAtStartup();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue