From 7acc208fe6c1a88f1237802f01593c957fc3c16c Mon Sep 17 00:00:00 2001 From: Josh Date: Tue, 14 Jul 2026 13:57:37 -0400 Subject: [PATCH] fix: key singleton mutex on config folder --- ErsatzTV/Program.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ErsatzTV/Program.cs b/ErsatzTV/Program.cs index 2bfcae1f0..8267492b5 100644 --- a/ErsatzTV/Program.cs +++ b/ErsatzTV/Program.cs @@ -1,6 +1,8 @@ using System.Diagnostics; using System.Globalization; using System.Runtime.InteropServices; +using System.Security.Cryptography; +using System.Text; using Destructurama; using ErsatzTV.Core; using ErsatzTV.Services.Validators; @@ -47,9 +49,14 @@ public class Program public static async Task Main(string[] args) { + // Keyed on the config folder, not a constant, so an instance running against an + // isolated ETV_CONFIG_FOLDER (a staging copy) can coexist with the primary one. + string singletonId = Convert.ToHexString( + SHA256.HashData(Encoding.UTF8.GetBytes(FileSystemLayout.AppDataFolder)))[..16]; + using var _ = new Mutex( true, - "Global\\ErsatzTV.Singleton.74360cd8985c4d1fb6bc9e81887206fe", + $"Global\\ErsatzTV.Singleton.{singletonId}", out bool createdNew); if (!createdNew) {