Skip to content

Commit 5c28a83

Browse files
committed
Fix a bug where corrupt installoptions files won't be overriden (fix #4087)
1 parent 75cd438 commit 5c28a83

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/Classes/InstallOptionsFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ private static void _saveToDisk(InstallOptions options, string key)
138138

139139
private static InstallOptions _loadFromDisk(string key)
140140
{
141+
var filePath = Path.Join(CoreData.UniGetUIInstallationOptionsDirectory, key);
141142
try
142143
{
143144
InstallOptions serializedOptions;
@@ -148,7 +149,6 @@ private static InstallOptions _loadFromDisk(string key)
148149
}
149150
else
150151
{
151-
var filePath = Path.Join(CoreData.UniGetUIInstallationOptionsDirectory, key);
152152
if (!File.Exists(filePath))
153153
{
154154
// If the file where it should be stored does not exist
@@ -170,7 +170,7 @@ private static InstallOptions _loadFromDisk(string key)
170170
catch (JsonException)
171171
{
172172
Logger.Warn("An error occurred while parsing package " + key + ". The file will be overwritten");
173-
File.WriteAllText(key, "{}");
173+
try { File.WriteAllText(filePath, "{}"); } catch (Exception ex) { Logger.Warn(ex); }
174174
return new();
175175
}
176176
catch (Exception e)

0 commit comments

Comments
 (0)