From 3ae0c0204fe0483731ab40330b0f070d3d689fc8 Mon Sep 17 00:00:00 2001 From: kawaiizenbo <48113593+kawaiizenbo@users.noreply.github.com> Date: Fri, 22 Oct 2021 15:30:51 -0700 Subject: [PATCH] failed list+fix for repos with colons --- RepoFullDownloader-Core/Program.cs | 33 ++++++++++++++---------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/RepoFullDownloader-Core/Program.cs b/RepoFullDownloader-Core/Program.cs index 270843f..515d1f4 100644 --- a/RepoFullDownloader-Core/Program.cs +++ b/RepoFullDownloader-Core/Program.cs @@ -96,7 +96,7 @@ namespace RepoFullDownloader_Core { link += "/"; } - string cleanLink = link.Replace("http://", "").Replace("/", "_"); + string cleanLink = link.TrimEnd('/').Replace("http://", "").Replace("https://", "").Replace("/", "_").Replace(":", "_"); Directory.CreateDirectory($"./output/{cleanLink}"); WebClient webClient = new WebClient(); // headers because some repos are 'interesting' @@ -168,34 +168,31 @@ namespace RepoFullDownloader_Core } // remove last one because ???? packages.RemoveAt(packages.Count - 1); + List failed = new List(); foreach(CydiaPackage p in packages) { // Download all packages on repo + Random r = new Random(); try { - Random r = new Random(); - try + string[] choppedUp = p.link.Split('/'); + string fileToDownload = keepOg ? $"./output/{cleanLink}/" + choppedUp[choppedUp.Length - 1] : $"./output/{cleanLink}/" + p.name + "-" + p.version + ".deb"; + if (File.Exists(fileToDownload)) { - string[] choppedUp = p.link.Split('/'); - string fileToDownload = keepOg ? $"./output/{cleanLink}/" + choppedUp[choppedUp.Length - 1] : $"./output/{cleanLink}/" + p.name + "-" + p.version + ".deb"; - if (File.Exists(fileToDownload)) - { - fileToDownload += "_" + r.Next(0000, 9999); - } - webClient.DownloadFile(new Uri(link + p.link), fileToDownload); - Console.WriteLine("Successfully downloaded " + link + p.link + " as " + fileToDownload); - } - catch (Exception e) - { - Console.WriteLine("Could not download " + link + p.link); - Console.WriteLine(e.Message); + fileToDownload += "_" + r.Next(0000, 9999); } + webClient.DownloadFile(new Uri(link + p.link), fileToDownload); + Console.WriteLine("Successfully downloaded " + link + p.link + " as " + fileToDownload); } - catch (ArgumentOutOfRangeException) + catch (Exception e) { - Console.WriteLine("Finished downloading " + link); + Console.WriteLine("Could not download " + link + p.link); + Console.WriteLine(e.Message); + failed.Add(link + p.link); } } + Console.WriteLine("Finished downloading " + link); + if(failed.Count != 0) File.WriteAllLines($"./output/{cleanLink}/failed.txt", failed); } static void DownloadInstallerRepo(string link)