Skip to content

Commit

Permalink
fixed crash while converting old config
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsfds committed Jun 1, 2024
1 parent 607ead6 commit c04cbd8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>0.10.0</Version>
<Version>0.10.1</Version>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand Down
24 changes: 17 additions & 7 deletions src/ClientCommon/Config/ConfigProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,23 +254,33 @@ private void ConvertOldConfig()
_dbContext.Settings.Add(new() { Name = nameof(config.SkipStartup), Value = config.SkipStartup.ToString() });

_dbContext.Settings.Add(new() { Name = nameof(config.UseLocalApi), Value = config.UseLocalApi.ToString() });
_dbContext.Settings.Add(new() { Name = nameof(config.ApiPassword), Value = config.ApiPassword });
_dbContext.Settings.Add(new() { Name = nameof(config.ApiPassword), Value = config.ApiPassword ?? string.Empty });

foreach (var addon in config.Upvotes)
if (config.Upvotes is not null)
{
_dbContext.Scores.Add(new() { AddonId = addon.Key, IsUpvoted = addon.Value });
foreach (var addon in config.Upvotes)
{
_dbContext.Scores.Add(new() { AddonId = addon.Key, IsUpvoted = addon.Value });
}
}

foreach (var addon in config.DisabledAutoloadMods)
if (config.DisabledAutoloadMods is not null)
{
_dbContext.DisabledAddons.Add(new() { AddonId = addon });
foreach (var addon in config.DisabledAutoloadMods)
{
_dbContext.DisabledAddons.Add(new() { AddonId = addon });
}
}

foreach (var addon in config.Playtimes)
if (config.Playtimes is not null)
{
_dbContext.Playtimes.Add(new() { AddonId = addon.Key, Playtime = addon.Value });
foreach (var addon in config.Playtimes)
{
_dbContext.Playtimes.Add(new() { AddonId = addon.Key, Playtime = addon.Value });
}
}


_dbContext.GamePaths.Add(new() { Game = "PathDuke3D", Path = config.GamePathDuke3D });
_dbContext.GamePaths.Add(new() { Game = "PathDukeWT", Path = config.GamePathDukeWT });
_dbContext.GamePaths.Add(new() { Game = "PathDuke64", Path = config.GamePathDuke64 });
Expand Down

0 comments on commit c04cbd8

Please sign in to comment.