Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core substitute #172

Merged
merged 5 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@
_writeMessage("Checking Core: " + name);
var mostRecentRelease = core.version;

await core.ReplaceCheck();

if(mostRecentRelease == null) {
_writeMessage("No releases found. Skipping");
await CopyBetaKey(core);
Expand Down Expand Up @@ -410,7 +412,7 @@
OnUpdateProcessComplete(args);
}

private void Divide()

Check warning on line 415 in src/Updater.cs

View workflow job for this annotation

GitHub Actions / build

'PocketCoreUpdater.Divide()' hides inherited member 'Base.Divide()'. Use the new keyword if hiding was intended.
{
_writeMessage("-------------");
}
Expand Down
38 changes: 37 additions & 1 deletion src/models/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
public string platform_id { get; set; }
public Sponsor? sponsor { get; set; }
public string? download_url { get; set; }
public string? date_release { get; set; }
public string? release_date { get; set; }
public string? version { get; set; }
public string[]? replaces { get; set; }
public string? betaSlotId = null;

public bool requires_license { get; set; } = false;
Expand Down Expand Up @@ -117,7 +118,7 @@
return p["platform"];
}

public bool UpdatePlatform(string title, string category = null)

Check warning on line 121 in src/models/Core.cs

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.
{
var config = this.getConfig();
if (config == null)
Expand Down Expand Up @@ -292,6 +293,28 @@
return config;
}

public Updater.Substitute[]? getSubstitutes()
{
checkUpdateDirectory();
string file = Path.Combine(Factory.GetGlobals().UpdateDirectory, "Cores", this.identifier, "updaters.json");
if (!File.Exists(file))
{
return null;
}
string json = File.ReadAllText(file);
var options = new JsonSerializerOptions()
{
AllowTrailingCommas = true
};
Updater.Updaters? config = JsonSerializer.Deserialize<Updater.Updaters>(json, options);

if (config == null) {
return null;
}

return config.previous;
}

public bool isInstalled()
{
checkUpdateDirectory();
Expand Down Expand Up @@ -504,12 +527,25 @@

return check;
}

public async Task ReplaceCheck()
{
if (replaces != null) {
foreach(string id in replaces) {
Core c = new Core(){identifier = id};
if (c.isInstalled()) {
c.Uninstall();
_writeMessage($"Uninstalled {id}. It was replaced by this core.");
}
}
}
}
}

public class myReverserClass : IComparer {

// Calls CaseInsensitiveComparer.Compare with the parameters reversed.
int IComparer.Compare( Object x, Object y ) {

Check warning on line 548 in src/models/Core.cs

View workflow job for this annotation

GitHub Actions / build

Nullability of reference types in type of parameter 'x' doesn't match implemented member 'int IComparer.Compare(object? x, object? y)' (possibly because of nullability attributes).

Check warning on line 548 in src/models/Core.cs

View workflow job for this annotation

GitHub Actions / build

Nullability of reference types in type of parameter 'y' doesn't match implemented member 'int IComparer.Compare(object? x, object? y)' (possibly because of nullability attributes).
return( (new CaseInsensitiveComparer()).Compare( y, x ) );
}
}
8 changes: 8 additions & 0 deletions src/models/Updater/Substitute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace pannella.analoguepocket.Updater;

public class Substitute
{
public string? platform{ get; set; }
public string? author { get; set; }
public string? shortname { get; set; }
}
6 changes: 6 additions & 0 deletions src/models/Updater/Updaters.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace pannella.analoguepocket.Updater;

public class Updaters
{
public Substitute[]? previous;
}
Loading