From 43893d7ae37fc0035665ccccdaa22cbe61a64814 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sat, 4 Jul 2026 04:14:27 +0200 Subject: [PATCH] Clean leftovers of previous run before MSI install test A killed run, or an uninstall that failed to remove files, leaves a non-empty data directory. Every subsequent MSI install on the worker then fails with 'data directory exists and is not empty'. Currently the case on amd64-windows-packages (builds 43478+). --- scripts/windows/msi-install.ps1 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scripts/windows/msi-install.ps1 b/scripts/windows/msi-install.ps1 index d864f19c0..9aa7ff5f9 100644 --- a/scripts/windows/msi-install.ps1 +++ b/scripts/windows/msi-install.ps1 @@ -5,6 +5,25 @@ param ( [string]$BuildDir = "." ) +# Clean up leftovers of a previous test run that did not complete its +# uninstall (e.g. was killed, or the uninstall failed to remove files). +# A leftover data directory makes the MSI installation fail with +# "data directory exists and is not empty", permanently, until the +# worker is cleaned. +$svc = Get-Service $ServiceName -ErrorAction SilentlyContinue +if ($svc) { + Write-Output "Removing leftover service $ServiceName" + if ($svc.Status -ne 'Stopped') { + Stop-Service $ServiceName -Force -ErrorAction SilentlyContinue + try { $svc.WaitForStatus('Stopped', '00:01:00') } catch {} + } + sc.exe delete $ServiceName | Out-Null +} +if (Test-Path $InstallDir) { + Write-Output "Removing leftover installation directory $InstallDir" + Remove-Item -Recurse -Force $InstallDir +} + # Look for the first MariaDB MSI file in the $BuildDir $msiFile = Get-ChildItem -Path $BuildDir -Filter "mariadb-*.msi" | Select-Object -First 1