Skip to content

Commit

Permalink
removed hardcoded path to settings file
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpannella committed Sep 10, 2022
1 parent 8795f01 commit 861ad12
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

Assets/
Cores/
Platforms/
Saves/
Spiritualized_*_readme.txt


# User-specific files
*.rsuser
*.suo
Expand Down
14 changes: 10 additions & 4 deletions Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class PocketCoreUpdater
/// </summary>
public string CoresFile { get; set; }

public string SettingsFile { get; set; }

/// <summary>
/// Constructor
/// </summary>
Expand All @@ -50,6 +52,8 @@ public PocketCoreUpdater(string updateDirectory, string coresFile = null)
throw new FileNotFoundException("Cores json file not found: " + coresFile);
}
}

SettingsFile = Path.Combine(updateDirectory, "pocket_updater_settings.json");
}

/// <summary>
Expand Down Expand Up @@ -293,9 +297,11 @@ public async Task UpdateFirmware()
string[] parts = firmwareUrl.Split("/");
string filename = parts[parts.Length-1];

string settingsfile = "/Users/mattpannella/development/c#/pocket_updater/pocket_updater_settings.json";
string json = File.ReadAllText(settingsfile);
Settings? coresList = JsonSerializer.Deserialize<Settings>(json);
Settings coresList = new Settings();
if(File.Exists(SettingsFile)) {
string json = File.ReadAllText(SettingsFile);
coresList = JsonSerializer.Deserialize<Settings>(json);
}
if(coresList.firmware.version != filename) {
_writeMessage("Firmware update found. Downloading...");
await HttpHelper.DownloadFileAsync(firmwareUrl, Path.Combine(UpdateDirectory, filename));
Expand All @@ -308,7 +314,7 @@ public async Task UpdateFirmware()
}
coresList.firmware.version = filename;
var options = new JsonSerializerOptions { WriteIndented = true };
File.WriteAllText(settingsfile, JsonSerializer.Serialize(coresList, options));
File.WriteAllText(SettingsFile, JsonSerializer.Serialize(coresList, options));
_writeMessage("To install firmware, restart your Pocket.");
} else {
_writeMessage("Firmware up to date.");
Expand Down

0 comments on commit 861ad12

Please sign in to comment.