FortFirewall.exe.ini: Add "updateDir" option

This commit is contained in:
Nodir Temirkhodjaev 2024-08-19 18:05:52 +05:00
parent 8cdeef7b57
commit 8b73c25eb0
9 changed files with 25 additions and 26 deletions

View File

@ -41,6 +41,10 @@
;Default is "<userDir>/logs".
;logsDir=%FORTHOME%/Data/logs
;Directory to store Fort Firewall's update.
;Default is "<cacheDir>".
;updateDir=%TEMP%/Fort Firewall
;Force debug output.
;forceDebug=true

View File

@ -15,22 +15,6 @@
#include <util/dateutil.h>
#include <util/iconcache.h>
namespace {
QString checkUpdateToolTip(TaskInfoUpdateChecker *updateChecker)
{
const QDateTime lastRun = updateChecker->lastRun();
const QDateTime lastSuccess = updateChecker->lastSuccess();
QString text = DateUtil::localeDateTime(lastRun);
if (lastRun != lastSuccess) {
text += " / " + DateUtil::localeDateTime(lastSuccess);
}
return text;
}
}
AboutPage::AboutPage(HomeController *ctrl, QWidget *parent) : HomeBasePage(ctrl, parent)
{
setupUi();
@ -134,8 +118,6 @@ void AboutPage::setupNewVersionUpdate()
m_progressBar->setRange(0, taskInfo->downloadSize());
m_btDownload->setVisible(m_isNewVersion && !m_btInstall->isVisible());
m_btCheckUpdate->setToolTip(checkUpdateToolTip(taskInfo));
retranslateNewVersionBox();
};
@ -168,6 +150,8 @@ void AboutPage::setupAutoUpdate()
m_btDownload->setVisible(isNewVersion && !isDownloadActive);
m_btInstall->setVisible(isNewVersion && isDownloaded);
m_btInstall->setToolTip(isDownloaded ? manager->installerPath() : QString());
};
refreshAutoUpdate();

View File

@ -74,7 +74,7 @@ inline void setupMasterServices(IocContainer *ioc, const FortSettings *settings)
ioc->setService(new StatManager(settings->statFilePath()));
ioc->setService(new StatBlockManager(settings->statBlockFilePath()));
ioc->setService(new AskPendingManager());
ioc->setService(new AutoUpdateManager(settings->cachePath()));
ioc->setService(new AutoUpdateManager(settings->updatePath()));
ioc->setService(new DriverManager());
ioc->setService(new AppInfoManager(settings->cacheFilePath()));
ioc->setService(new LogManager());
@ -96,7 +96,7 @@ inline void setupClientServices(IocContainer *ioc, const FortSettings *settings)
ioc->setService<StatManager>(new StatManagerRpc(settings->statFilePath()));
ioc->setService<StatBlockManager>(new StatBlockManagerRpc(settings->statBlockFilePath()));
ioc->setService<AskPendingManager>(new AskPendingManagerRpc());
ioc->setService<AutoUpdateManager>(new AutoUpdateManagerRpc(settings->cachePath()));
ioc->setService<AutoUpdateManager>(new AutoUpdateManagerRpc(settings->updatePath()));
ioc->setService<DriverManager>(new DriverManagerRpc());
ioc->setService<AppInfoManager>(
new AppInfoManagerRpc(settings->cacheFilePath(), settings->noCache()));

View File

@ -129,6 +129,7 @@ void FortSettings::setupGlobal()
m_cachePath = settings.value("global/cacheDir").toString();
m_userPath = settings.value("global/userDir").toString();
m_logsPath = settings.value("global/logsDir").toString();
m_updatePath = settings.value("global/updateDir").toString();
}
void FortSettings::initialize(const QStringList &args, EnvManager *envManager)
@ -337,6 +338,13 @@ void FortSettings::setupPaths(EnvManager *envManager)
} else {
m_logsPath = expandPath(m_logsPath, envManager);
}
// Update Path
if (m_updatePath.isEmpty()) {
m_updatePath = m_cachePath;
} else {
m_updatePath = expandPath(m_updatePath, envManager);
}
}
void FortSettings::createPaths()

View File

@ -64,6 +64,8 @@ public:
QString logsPath() const { return m_logsPath; }
QString updatePath() const { return m_updatePath; }
QString controlCommand() const { return m_controlCommand; }
const QStringList &args() const { return m_args; }
@ -153,6 +155,7 @@ private:
QString m_cachePath;
QString m_userPath;
QString m_logsPath;
QString m_updatePath;
QString m_controlCommand;
QStringList m_args;
};

View File

@ -23,8 +23,8 @@ constexpr int DownloadMaxTryCount = 3;
}
AutoUpdateManager::AutoUpdateManager(const QString &cachePath, QObject *parent) :
TaskDownloader(parent), m_updatePath(cachePath + "update/")
AutoUpdateManager::AutoUpdateManager(const QString &updatePath, QObject *parent) :
TaskDownloader(parent), m_updatePath(updatePath + "update/")
{
}

View File

@ -23,7 +23,7 @@ public:
Q_ENUM(Flag)
Q_DECLARE_FLAGS(Flags, Flag)
explicit AutoUpdateManager(const QString &cachePath, QObject *parent = nullptr);
explicit AutoUpdateManager(const QString &updatePath, QObject *parent = nullptr);
Flags flags() const { return m_flags; }
void setFlags(Flags v);

View File

@ -61,8 +61,8 @@ inline bool processAutoUpdateManagerRpcResult(
}
AutoUpdateManagerRpc::AutoUpdateManagerRpc(const QString &cachePath, QObject *parent) :
AutoUpdateManager(cachePath, parent)
AutoUpdateManagerRpc::AutoUpdateManagerRpc(const QString &updatePath, QObject *parent) :
AutoUpdateManager(updatePath, parent)
{
}

View File

@ -13,7 +13,7 @@ class AutoUpdateManagerRpc : public AutoUpdateManager
Q_OBJECT
public:
explicit AutoUpdateManagerRpc(const QString &cachePath, QObject *parent = nullptr);
explicit AutoUpdateManagerRpc(const QString &updatePath, QObject *parent = nullptr);
int bytesReceived() const override { return m_bytesReceived; }
void setBytesReceived(int v);