Skip to content

Commit

Permalink
Updaters json license bug fix (#357)
Browse files Browse the repository at this point in the history
* fixed license file check
wipe updaters.json before installing cores

* patch bump

* constant
  • Loading branch information
mattpannella authored Nov 2, 2024
1 parent aa018ed commit ece664f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pupdate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
<Version>3.19.0</Version>
<Version>3.19.1</Version>
<Description>Keep your Analogue Pocket up to date</Description>
<Copyright>2024 Matt Pannella</Copyright>
<Authors>Matt Pannella</Authors>
Expand Down
6 changes: 5 additions & 1 deletion src/services/CoresService.Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ private bool CheckLicenseMd5(DataSlot slot, string licenseSlotId, string platfor

public bool CheckLicenseFile(Core core)
{
return File.Exists(Path.Combine(this.installPath, LICENSE_EXTRACT_LOCATION, core.updaters?.license.filename));
if (core.updaters?.license.filename != null)
{
return File.Exists(Path.Combine(this.installPath, LICENSE_EXTRACT_LOCATION, core.updaters.license.filename));
}
return false;
}
}
2 changes: 1 addition & 1 deletion src/services/CoresService.Json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Video ReadVideoJson(string identifier)

public Updaters ReadUpdatersJson(string identifier)
{
string file = Path.Combine(this.installPath, "Cores", identifier, "updaters.json");
string file = Path.Combine(this.installPath, "Cores", identifier, UPDATERS_FILE);

if (!File.Exists(file))
{
Expand Down
2 changes: 1 addition & 1 deletion src/services/CoresService.Replace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public partial class CoresService
{
public Substitute[] GetSubstitutes(string identifier)
{
string file = Path.Combine(this.installPath, "Cores", identifier, "updaters.json");
string file = Path.Combine(this.installPath, "Cores", identifier, UPDATERS_FILE);

if (!File.Exists(file))
{
Expand Down
14 changes: 14 additions & 0 deletions src/services/CoresService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public partial class CoresService : BaseProcess
{
private const string CORES_END_POINT = "https://openfpga-cores-inventory.github.io/analogue-pocket/api/v2/cores.json";
private const string CORES_FILE = "cores.json";

private const string UPDATERS_FILE = "updaters.json";
private const string ZIP_FILE_NAME = "core.zip";

private readonly string installPath;
Expand Down Expand Up @@ -222,6 +224,8 @@ public bool Install(Core core, bool clean = false)
return false;
}

this.ClearUpdatersFile(core.identifier);

if (clean && this.IsInstalled(core.identifier))
{
this.Delete(core.identifier, core.platform_id);
Expand Down Expand Up @@ -254,6 +258,16 @@ public bool Install(Core core, bool clean = false)
return false;
}

public void ClearUpdatersFile(string identifier)
{
string file = Path.Combine(this.installPath, "Cores", identifier, UPDATERS_FILE);

if (this.IsInstalled(identifier) && File.Exists(file))
{
File.Delete(file);
}
}

public void Uninstall(string identifier, string platformId, bool nuke = false)
{
WriteMessage($"Uninstalling {identifier}...");
Expand Down

0 comments on commit ece664f

Please sign in to comment.