Browse Source

Fix settings env var conflict

pull/629/head
Ionite 7 months ago
parent
commit
49aa554257
No known key found for this signature in database
  1. 20
      StabilityMatrix.Core/Models/Settings/Settings.cs

20
StabilityMatrix.Core/Models/Settings/Settings.cs

@ -118,10 +118,22 @@ public class Settings
public Dictionary<string, string>? UserEnvironmentVariables { get; set; }
[JsonIgnore]
public IReadOnlyDictionary<string, string> EnvironmentVariables =>
DefaultEnvironmentVariables
.Concat(UserEnvironmentVariables ?? [])
.ToDictionary(x => x.Key, x => x.Value);
public IReadOnlyDictionary<string, string> EnvironmentVariables
{
get
{
if (UserEnvironmentVariables is null || UserEnvironmentVariables.Count == 0)
{
return DefaultEnvironmentVariables;
}
return DefaultEnvironmentVariables
.Concat(UserEnvironmentVariables)
.GroupBy(pair => pair.Key)
// User variables override default variables with the same key
.ToDictionary(grouping => grouping.Key, grouping => grouping.Last().Value);
}
}
public HashSet<string>? InstalledModelHashes { get; set; } = new();

Loading…
Cancel
Save