Skip to content

Commit

Permalink
Core specific custom archive (#358)
Browse files Browse the repository at this point in the history
* wip

* wip

* think this works

* version
  • Loading branch information
mattpannella authored Nov 6, 2024
1 parent ece664f commit 4361ca3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
3 changes: 2 additions & 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.1</Version>
<Version>3.20.0</Version>
<Description>Keep your Analogue Pocket up to date</Description>
<Copyright>2024 Matt Pannella</Copyright>
<Authors>Matt Pannella</Authors>
Expand All @@ -20,6 +20,7 @@
<PackageReference Include="Crc32.NET" Version="1.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" />
<PackageReference Include="UrlCombine" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<EditorConfigFiles Remove=".editorconfig" />
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/ContactResolvers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected override JsonProperty CreateProperty(MemberInfo member, MemberSerializ
{
Archive archive = (Archive)instance;

return archive.type == ArchiveType.core_specific_archive;
return (archive.type == ArchiveType.core_specific_archive || archive.type == ArchiveType.core_specific_custom_archive);
};
}

Expand Down
3 changes: 2 additions & 1 deletion src/models/Settings/Archive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public enum ArchiveType
internet_archive,
custom_archive,
core_specific_archive,
core_specific_custom_archive,
}

public class Archive
Expand Down Expand Up @@ -38,5 +39,5 @@ public class Archive
/// <summary>
/// This setting only applies to Core Specific Archives
/// </summary>
public bool enabled;
public bool enabled { get; set; }
}
15 changes: 6 additions & 9 deletions src/services/ArchiveService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using SettingsArchive = Pannella.Models.Settings.Archive;
using ArchiveFile = Pannella.Models.Archive.File;
using Archive = Pannella.Models.Archive.Archive;
using UrlCombineLib;

namespace Pannella.Services;

Expand Down Expand Up @@ -67,12 +68,11 @@ public IEnumerable<ArchiveFile> GetArchiveFiles(SettingsArchive archive)
{
WriteMessage($"Loading Assets Index for '{archive.archive_name}'...");

if (useCustomArchive && archive.type != ArchiveType.core_specific_archive)
if ((useCustomArchive && archive.type != ArchiveType.core_specific_archive) || archive.type == ArchiveType.core_specific_custom_archive)
{
Uri baseUrl = new Uri(archive.url);
Uri url = new Uri(baseUrl, archive.index);
string url = UrlCombine.Combine(archive.url, archive.index);

internetArchive = ArchiveService.GetFilesCustom(url.ToString());
internetArchive = ArchiveService.GetFilesCustom(url);
}
else
{
Expand Down Expand Up @@ -126,12 +126,9 @@ public bool DownloadArchiveFile(SettingsArchive archive, ArchiveFile archiveFile
{
string url;

if (archive.type == ArchiveType.custom_archive)
if (archive.type == ArchiveType.custom_archive || archive.type == ArchiveType.core_specific_custom_archive)
{
Uri baseUrl = new Uri(archive.url);
Uri uri = new Uri(baseUrl, archiveFile.name);

url = uri.ToString();
url = UrlCombine.Combine(archive.url, archiveFile.name).ToString();
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/services/CoresService.Download.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public Dictionary<string, object> DownloadAssets(Core core, bool ignoreGlobalSet
}
}

if (archive.type == ArchiveType.core_specific_archive && archive.enabled && !archive.has_instance_jsons)
if ((archive.type == ArchiveType.core_specific_archive || archive.type == ArchiveType.core_specific_custom_archive) && archive.enabled && !archive.has_instance_jsons)
{
var files = this.archiveService.GetArchiveFiles(archive);

Expand Down

0 comments on commit 4361ca3

Please sign in to comment.