fix(host): clear pooled SQLite handles before renaming the imported inbound-key file — Windows refused the rename, so the import re-ran every boot (QA vq03/vq04 2026-10-22)

This commit is contained in:
Joseph Doherty
2026-10-22 15:56:00 -04:00
parent 5ad6f83176
commit 6ed6800b84
3 changed files with 61 additions and 0 deletions
@@ -1,4 +1,5 @@
using Microsoft.Data.SqlClient;
using Microsoft.Data.Sqlite;
using Microsoft.Extensions.Options;
using ZB.MOM.WW.Auth.Abstractions.ApiKeys;
using ZB.MOM.WW.Auth.ApiKeys.SqlServer;
@@ -112,6 +113,12 @@ internal sealed class InboundApiKeyStoreImportService(
path, result.KeysInserted, result.KeysSkipped,
result.AuditInserted, result.AuditSkipped, result.SourceFound);
// The library importer reads the file through a POOLED SqliteConnection, and the pool
// keeps the OS handle open after the connection is disposed. Linux renames an open file
// happily, but Windows refuses ("being used by another process"), so on a Windows
// central the rename failed on every boot and the import re-ran each time (QA
// vq03/vq04, 2026-10-22). Drop the idle pooled handles first.
SqliteConnection.ClearAllPools();
RenameImported(path);
}
catch (Exception ex)