Skip to content

Commit

Permalink
Merge pull request #53 from mattpannella/develop
Browse files Browse the repository at this point in the history
pull Develop
  • Loading branch information
mattpannella authored Nov 6, 2022
2 parents 1aa40be + de0a2b6 commit 45d7044
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 21 deletions.
61 changes: 41 additions & 20 deletions Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public async Task RunUpdates()
foreach(Core core in _cores) {
try {
if(_settingsManager.GetCoreSettings(core.identifier).skip) {
// _DeleteCore(core);
continue;
}
//bandaid. just skip these for now
Expand Down Expand Up @@ -377,25 +378,29 @@ private async Task<List<string>> _DownloadAssets(Dependency assets)
if(File.Exists(filePath)) {
_writeMessage("Asset already installed: " + file.file_name);
} else {
string url = BuildAssetUrl(file);
if(file.zip) {
string zipFile = Path.Combine(path, "roms.zip");
_writeMessage("Downloading zip file...");
await HttpHelper.DownloadFileAsync(url, zipFile);
string extractPath = Path.Combine(UpdateDirectory, "temp");
_writeMessage("Extracting files...");
ZipFile.ExtractToDirectory(zipFile, extractPath, true);
_writeMessage("Moving file: " + file.file_name);
File.Move(Path.Combine(extractPath, file.zip_file), filePath);
_writeMessage("Deleting temp files");
Directory.Delete(extractPath, true);
File.Delete(zipFile);
installed.Add(filePath);
} else {
_writeMessage("Downloading " + file.file_name);
await HttpHelper.DownloadFileAsync(url, filePath);
_writeMessage("Finished downloading " + file.file_name);
installed.Add(filePath);
try {
string url = BuildAssetUrl(file);
if(file.zip) {
string zipFile = Path.Combine(path, "roms.zip");
_writeMessage("Downloading zip file...");
await HttpHelper.DownloadFileAsync(url, zipFile);
string extractPath = Path.Combine(UpdateDirectory, "temp");
_writeMessage("Extracting files...");
ZipFile.ExtractToDirectory(zipFile, extractPath, true);
_writeMessage("Moving file: " + file.file_name);
File.Move(Path.Combine(extractPath, file.zip_file), filePath);
_writeMessage("Deleting temp files");
Directory.Delete(extractPath, true);
File.Delete(zipFile);
installed.Add(filePath);
} else {
_writeMessage("Downloading " + file.file_name);
await HttpHelper.DownloadFileAsync(url, filePath);
_writeMessage("Finished downloading " + file.file_name);
installed.Add(filePath);
}
} catch(Exception e) {
_writeMessage(e.Message);
}
}
}
Expand Down Expand Up @@ -480,7 +485,7 @@ private async Task<bool> _getAsset(string downloadLink, string coreName)
private async Task<bool> _fetchCustomRelease(Core core)
{
string zip_name = core.identifier + "_" + core.release.tag_name + ".zip";
Github.File file = await GithubApi.GetFile(core.repository.owner, core.repository.name, core.release_path + "/" + zip_name);
Github.File file = await GithubApi.GetFile(core.repository.owner, core.repository.name, core.release_path + "/" + zip_name, _githubApiKey);

_writeMessage("Downloading file " + file.download_url + "...");
string zipPath = Path.Combine(UpdateDirectory, ZIP_FILE_NAME);
Expand Down Expand Up @@ -572,6 +577,22 @@ public void ExtractAll(bool value)
_extractAll = value;
}

private void _DeleteCore(Core core)
{
// if(!_settingsManager.GetConfig().delete_skipped_cores) {
// return;
// }

// if(core.release.assets.Count > 0) {
//Assets/core.release.assets[0].platform
//delete me
// }
//delete Cores/core.identifier

//delete Platforms/need platform name somehow
// Directory.Delete
}

/// <summary>
/// Event is raised every time the updater prints a progress update
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion pocket_updater.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>2.6.1</Version>
<Version>2.6.2</Version>
<Description>Keep your Analogue Pocket up to date</Description>
<Copyright>2022 Matt Pannella</Copyright>
<Authors>Matt Pannella</Authors>
Expand Down

0 comments on commit 45d7044

Please sign in to comment.