Skip to content

Commit

Permalink
Merge pull request #113 from Corona-Studio/hotfix
Browse files Browse the repository at this point in the history
[BugFix] minor fix for FileParser
  • Loading branch information
laolarou726 committed Jan 18, 2024
2 parents 7c8888e + bd1d168 commit 16d6c5b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public bool RemoveAccount(Guid id)
var result = Find(id);
if (!result.HasValue) return false;

var (key, value) = result.Value;
var (key, _) = result.Value;

LauncherAccount?.Accounts?.Remove(key);
Save();
Expand All @@ -155,13 +155,21 @@ public bool RemoveAccount(Guid id)

public void Save()
{
if (File.Exists(_fullLauncherAccountPath))
File.Delete(_fullLauncherAccountPath);

var launcherProfileJson =
JsonSerializer.Serialize(LauncherAccount, typeof(LauncherAccountModel),
new LauncherAccountModelContext(JsonHelper.CamelCasePropertyNamesSettings()));

File.WriteAllText(_fullLauncherAccountPath, launcherProfileJson);
for (var i = 0; i < 3; i++)
{
try
{
File.WriteAllText(_fullLauncherAccountPath, launcherProfileJson);
break;
}
catch (IOException)
{
if (i == 2) throw;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,22 @@ public void RemoveGameProfile(string name)

public void SaveProfile()
{
if (File.Exists(_fullLauncherProfilePath))
File.Delete(_fullLauncherProfilePath);

var launcherProfileJson =
JsonSerializer.Serialize(LauncherProfile, typeof(LauncherProfileModel),
new LauncherProfileModelContext(JsonHelper.CamelCasePropertyNamesSettings()));

File.WriteAllText(_fullLauncherProfilePath, launcherProfileJson);
for (var i = 0; i < 3; i++)
{
try
{
File.WriteAllText(_fullLauncherProfilePath, launcherProfileJson);
break;
}
catch (IOException)
{
if (i == 2) throw;
}
}
}

public void SelectGameProfile(string name)
Expand Down

0 comments on commit 16d6c5b

Please sign in to comment.