fix(ports): write both hashed and legacy port files; compare project paths case-insensitively to prevent sticky-port drift across reloads
parent
85202d4ccb
commit
1b892dcf49
|
|
@ -38,7 +38,7 @@ namespace UnityMcpBridge.Editor.Helpers
|
||||||
var storedConfig = GetStoredPortConfig();
|
var storedConfig = GetStoredPortConfig();
|
||||||
if (storedConfig != null &&
|
if (storedConfig != null &&
|
||||||
storedConfig.unity_port > 0 &&
|
storedConfig.unity_port > 0 &&
|
||||||
storedConfig.project_path == Application.dataPath &&
|
string.Equals(storedConfig.project_path ?? string.Empty, Application.dataPath ?? string.Empty, StringComparison.OrdinalIgnoreCase) &&
|
||||||
IsPortAvailable(storedConfig.unity_port))
|
IsPortAvailable(storedConfig.unity_port))
|
||||||
{
|
{
|
||||||
Debug.Log($"Using stored port {storedConfig.unity_port} for current project");
|
Debug.Log($"Using stored port {storedConfig.unity_port} for current project");
|
||||||
|
|
@ -196,7 +196,11 @@ namespace UnityMcpBridge.Editor.Helpers
|
||||||
|
|
||||||
string registryFile = GetRegistryFilePath();
|
string registryFile = GetRegistryFilePath();
|
||||||
string json = JsonConvert.SerializeObject(portConfig, Formatting.Indented);
|
string json = JsonConvert.SerializeObject(portConfig, Formatting.Indented);
|
||||||
|
// Write to hashed, project-scoped file
|
||||||
File.WriteAllText(registryFile, json);
|
File.WriteAllText(registryFile, json);
|
||||||
|
// Also write to legacy stable filename to avoid hash/case drift across reloads
|
||||||
|
string legacy = Path.Combine(GetRegistryDirectory(), RegistryFileName);
|
||||||
|
File.WriteAllText(legacy, json);
|
||||||
|
|
||||||
Debug.Log($"Saved port {port} to storage");
|
Debug.Log($"Saved port {port} to storage");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue