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" case 's': { // "service"
StartupUtil::setAutoRunMode(StartupUtil::StartupAllUsers); StartupUtil::setAutoRunMode(StartupUtil::StartupAllUsers);
StartupUtil::setServiceInstalled(true); StartupUtil::setServiceInstalled(true);
OsUtil::endRestartClients();
} break; } break;
case 'e': { // "explorer" case 'e': { // "explorer"
StartupUtil::setExplorerIntegrated(true); StartupUtil::setExplorerIntegrated(true);

View File

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

View File

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

View File

@ -180,6 +180,16 @@ bool OsUtil::registerAppRestart()
RegisterApplicationRestart(L"--restarted", RESTART_NO_CRASH | RESTART_NO_REBOOT)); 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() void OsUtil::restartClient()
{ {
const QFileInfo fi(QCoreApplication::applicationFilePath()); const QFileInfo fi(QCoreApplication::applicationFilePath());

View File

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