Skip to content

Commit

Permalink
Even more tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
RetroDriven committed May 12, 2024
1 parent 6738fba commit d158b0d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
38 changes: 23 additions & 15 deletions Controls/Update_Pocket/Update_Pocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using Guna.UI2.WinForms;
using Pannella.Models.Settings;
using Microsoft.VisualBasic;
using Pocket_Updater.Properties;
using System.Runtime;

namespace Pocket_Updater.Controls
{
Expand All @@ -33,10 +35,11 @@ public Update_Pocket()

//Get USB Drives
PopulateDrives();

string Current_Dir = Directory.GetCurrentDirectory();
_settings = new SettingsService(Current_Dir);

setupUpdater(Current_Dir);
setupUpdater(Current_Dir, Current_Dir);

Update.Enabled = false;

Expand All @@ -45,7 +48,6 @@ public Update_Pocket()

//Preferences
Get_Preferences_Json();

}
public async Task RunCoreUpdateProcess(string updatePath, string coresJsonPath, string LogDir)
{
Expand Down Expand Up @@ -143,7 +145,7 @@ private async Task UpdateCurrentDirectory(string github_token, string currentDir
try
{
//Download_Json(Current_Dir);
setupUpdater(currentDirectory);
setupUpdater(currentDirectory,currentDirectory);

//Progress Bar
HttpHelper.Instance.DownloadProgressUpdate += updater_ProgressUpdated;
Expand Down Expand Up @@ -174,7 +176,7 @@ private async Task UpdateRemoveableStorage(string github_token, string currentDi
var drives = DriveInfo.GetDrives();
if (drives.Where(data => data.Name == pathToUpdate).Count() == 1)
{
setupUpdater(pathToUpdate);
setupUpdater(pathToUpdate, currentDirectory);

//Progress Bar
HttpHelper.Instance.DownloadProgressUpdate += updater_ProgressUpdated;
Expand Down Expand Up @@ -646,8 +648,14 @@ private async void Save_Settings(string ShowBox)
}

//Save Sttings
ServiceHelper.SettingsService.UpdateConfig(config);
ServiceHelper.SettingsService.Save();
SettingsService _settings;
string Current_Dir = Directory.GetCurrentDirectory();
_settings = new SettingsService(Current_Dir);

_settings.UpdateConfig(config);
_settings.Save();
//ServiceHelper.SettingsService.UpdateConfig(config);
//ServiceHelper.SettingsService.Save();


//Show Message Box
Expand Down Expand Up @@ -731,16 +739,16 @@ private void Save_Preferences_Json()
Updater_Preferences.Save_Updater_Json(Entries, Json_File);
}
}
private void setupUpdater(string path)
private void setupUpdater(string path, string config_path)
{
ServiceHelper.Initialize(path, updater_StatusUpdated, _updater_UpdateProcessComplete, true);
_updater = new CoreUpdaterService(
ServiceHelper.UpdateDirectory,
ServiceHelper.CoresService.Cores,
ServiceHelper.FirmwareService,
ServiceHelper.SettingsService,
ServiceHelper.CoresService
);
ServiceHelper.Initialize(path, config_path, updater_StatusUpdated, _updater_UpdateProcessComplete, true);
_updater = new CoreUpdaterService(
ServiceHelper.UpdateDirectory,
ServiceHelper.CoresService.Cores,
ServiceHelper.FirmwareService,
ServiceHelper.SettingsService,
ServiceHelper.CoresService
);

_updater.StatusUpdated += updater_StatusUpdated;
_updater.UpdateProcessComplete += _updater_UpdateProcessComplete;
Expand Down
4 changes: 2 additions & 2 deletions lib/Updater/helpers/ServiceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public static class ServiceHelper
private static bool isInitialized;

public static void Initialize(string path, EventHandler<StatusUpdatedEventArgs> statusUpdated = null,
EventHandler<UpdateProcessCompleteEventArgs> updateProcessComplete = null, bool forceReload = false)
EventHandler<UpdateProcessCompleteEventArgs> updateProcessComplete = null)
{
if (!isInitialized || forceReload)
if (!isInitialized)
{
isInitialized = true;
UpdateDirectory = path;
Expand Down

0 comments on commit d158b0d

Please sign in to comment.