From 80932f8da11d52cadc021d45d460b6787535d3e3 Mon Sep 17 00:00:00 2001 From: Felipe <54341095+Pipe530@users.noreply.github.com> Date: Wed, 21 Oct 2026 15:43:30 -0300 Subject: [PATCH] Remove leftover update workspace folders on launcher startup (#1782) * Remove leftover update workspace folders on launcher startup Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Skip recently active update workspaces during cleanup Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Keep update workspaces for an hour before cleanup so Windows downloads are not removed --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: nmzik --- src/launcher/src/updateChecker.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/launcher/src/updateChecker.cpp b/src/launcher/src/updateChecker.cpp index e7d6680dd..b44791861 100644 --- a/src/launcher/src/updateChecker.cpp +++ b/src/launcher/src/updateChecker.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -96,7 +97,27 @@ bool UpdateChecker::IsSupported() { void UpdateChecker::ShowPreviousResult(QWidget* parent) { const auto directory = InstallDirectory(); - QFile result(QDir(directory).filePath(QStringLiteral(".kyty-update-result"))); + if (!directory.isEmpty()) { + // The helper cannot delete its own executable on Windows, so its workspace is + // removed by the next launcher start. + const QDir install(directory); + for (const auto& name: + install.entryList({QStringLiteral(".kyty-update-??????")}, + QDir::Dirs | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot)) { + QDir workspace(install.filePath(name)); + QDateTime newest = QFileInfo(workspace.path()).lastModified(); + for (const auto& entry: workspace.entryInfoList(QDir::Files | QDir::Dirs | QDir::Hidden | + QDir::NoDotAndDotDot)) { + newest = qMax(newest, entry.lastModified()); + } + // A workspace touched recently may belong to a running download or helper. Windows + // lists a file still being downloaded with a stale time, so allow a generous margin. + if (newest.secsTo(QDateTime::currentDateTime()) > 60 * 60) { + workspace.removeRecursively(); + } + } + } + QFile result(QDir(directory).filePath(QStringLiteral(".kyty-update-result"))); if (directory.isEmpty() || !result.open(QIODevice::ReadOnly)) { return; }