2
0

Fix missing file on loading settings/commonobjects

This commit is contained in:
glax 2023-07-31 00:01:18 +02:00
parent 3d6657b483
commit fa19d3da14
2 changed files with 22 additions and 8 deletions

View File

@ -53,6 +53,7 @@ public class CommonObjects
public void ExportSettings()
{
TrangaSettings.SettingsJsonObject? settings = null;
if (File.Exists(settingsFilePath))
{
bool inUse = true;
@ -70,11 +71,17 @@ public class CommonObjects
Thread.Sleep(50);
}
}
string toRead = File.ReadAllText(settingsFilePath);
settings = JsonConvert.DeserializeObject<TrangaSettings.SettingsJsonObject>(toRead,
new JsonSerializerSettings
{
Converters =
{
new NotificationManager.NotificationManagerJsonConverter(),
new LibraryManager.LibraryManagerJsonConverter()
}
});
}
string toRead = File.ReadAllText(settingsFilePath);
TrangaSettings.SettingsJsonObject? settings = JsonConvert.DeserializeObject<TrangaSettings.SettingsJsonObject>(toRead,
new JsonSerializerSettings { Converters = { new NotificationManager.NotificationManagerJsonConverter(), new LibraryManager.LibraryManagerJsonConverter() } });
settings = new TrangaSettings.SettingsJsonObject(settings?.ts, this);
File.WriteAllText(settingsFilePath, JsonConvert.SerializeObject(settings));
}

View File

@ -37,6 +37,7 @@ public class TrangaSettings
public void ExportSettings()
{
SettingsJsonObject? settings = null;
if (File.Exists(settingsFilePath))
{
bool inUse = true;
@ -54,11 +55,17 @@ public class TrangaSettings
Thread.Sleep(50);
}
}
string toRead = File.ReadAllText(settingsFilePath);
settings = JsonConvert.DeserializeObject<SettingsJsonObject>(toRead,
new JsonSerializerSettings
{
Converters =
{
new NotificationManager.NotificationManagerJsonConverter(),
new LibraryManager.LibraryManagerJsonConverter()
}
});
}
string toRead = File.ReadAllText(settingsFilePath);
SettingsJsonObject? settings = JsonConvert.DeserializeObject<SettingsJsonObject>(toRead,
new JsonSerializerSettings { Converters = { new NotificationManager.NotificationManagerJsonConverter(), new LibraryManager.LibraryManagerJsonConverter() } });
settings = new SettingsJsonObject(this, settings?.co);
File.WriteAllText(settingsFilePath, JsonConvert.SerializeObject(settings));
}