Skip to content

Commit

Permalink
device config fixes for first-time users
Browse files Browse the repository at this point in the history
  • Loading branch information
Aytackydln committed Jan 22, 2024
1 parent 16eb8a2 commit 5901b87
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project-Aurora/Project-Aurora/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ protected override async void OnStartup(StartupEventArgs e)

//Load config
Global.logger.Information("Loading Configuration");
Global.Configuration = ConfigManager.Load();
Global.DeviceConfiguration = ConfigManager.LoadDeviceConfig();
Global.Configuration = ConfigManager.Load();

Global.effengine = new Effects(DevicesModule.DeviceManager);

Expand Down
18 changes: 14 additions & 4 deletions Project-Aurora/Project-Aurora/Settings/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private static Configuration TryLoad()
}

App.ForceShutdownApp(-1);
throw new Exception();
throw new ApplicationException("irrelevant message");
}
}

Expand Down Expand Up @@ -90,8 +90,18 @@ public static DeviceConfig LoadDeviceConfig()
private static DeviceConfig TryLoadDevice()
{
if (!File.Exists(DeviceConfig.ConfigFile))
return MigrateDeviceConfig();

{
if (File.Exists(Configuration.ConfigFile))
// v194 Migration
return MigrateDeviceConfig();

// first time start
var deviceConfig = new DeviceConfig();
Save(deviceConfig, DeviceConfig.ConfigFile);
return deviceConfig;

}

var content = File.ReadAllText(DeviceConfig.ConfigFile, Encoding.UTF8);
return JsonConvert.DeserializeObject<DeviceConfig>(content,
new JsonSerializerSettings
Expand Down Expand Up @@ -139,7 +149,7 @@ private static DeviceConfig MigrateDeviceConfig()
ObjectCreationHandling = ObjectCreationHandling.Replace,
SerializationBinder = new AuroraSerializationBinder(),
}) ?? new DeviceConfig();
File.Copy(Configuration.ConfigFile, Configuration.ConfigFile + ".v194");
File.Copy(Configuration.ConfigFile, Configuration.ConfigFile + ".v194", true);
return config;
}
}

0 comments on commit 5901b87

Please sign in to comment.