UI: Create/remove an "inst.tmp" by Service early

This commit is contained in:
Nodir Temirkhodjaev 2024-05-23 10:00:36 +03:00
parent df7757c2ea
commit df812cb097
5 changed files with 27 additions and 1 deletions

View File

@ -267,6 +267,8 @@ void FortManager::install(const char *arg)
case 's': { // "service"
StartupUtil::setAutoRunMode(StartupUtil::StartupAllUsers);
StartupUtil::setServiceInstalled(true);
OsUtil::endRestartClients();
} break;
case 'e': { // "explorer"
StartupUtil::setExplorerIntegrated(true);

View File

@ -83,7 +83,7 @@ void AutoUpdateManager::setupRestart()
{
if (IoC<FortSettings>()->isService()) {
connect(IoC<ServiceManager>(), &ServiceManager::stopRestartingRequested, this,
&AutoUpdateManager::restartClients);
&AutoUpdateManager::onRestartClientsRequested);
} else {
if (!OsUtil::registerAppRestart()) {
qCWarning(LC) << "Restart registration error";
@ -146,6 +146,15 @@ void AutoUpdateManager::setupByTaskInfo(TaskInfoUpdateChecker *taskInfo)
setIsDownloaded(downloaded);
}
void AutoUpdateManager::onRestartClientsRequested(bool restarting)
{
if (restarting) {
OsUtil::beginRestartClients();
}
emit restartClients(restarting);
}
void AutoUpdateManager::clearUpdateDir()
{
if (isDownloaded())

View File

@ -74,6 +74,8 @@ protected slots:
private:
void setupByTaskInfo(TaskInfoUpdateChecker *taskInfo);
void onRestartClientsRequested(bool restarting);
void clearUpdateDir();
bool saveInstaller(const QByteArray &fileData);

View File

@ -180,6 +180,16 @@ bool OsUtil::registerAppRestart()
RegisterApplicationRestart(L"--restarted", RESTART_NO_CRASH | RESTART_NO_REBOOT));
}
void OsUtil::beginRestartClients()
{
FileUtil::writeFileData(FileUtil::appBinLocation() + "/inst.tmp", {});
}
void OsUtil::endRestartClients()
{
FileUtil::removeFile(FileUtil::appBinLocation() + "/inst.tmp");
}
void OsUtil::restartClient()
{
const QFileInfo fi(QCoreApplication::applicationFilePath());

View File

@ -44,7 +44,10 @@ public:
static bool registerAppRestart();
static void beginRestartClients();
static void endRestartClients();
static void restartClient();
static void restart();
static void quit(const QString &reason);
};