Skip to content

Commit

Permalink
v0.8.7.1-beta
Browse files Browse the repository at this point in the history
Added Fetching Progress Info
Changed WebClient Position
Changed Download Thread to Background
  • Loading branch information
StellarUpdater committed Mar 7, 2018
1 parent df171da commit 95108ac
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 23 deletions.
28 changes: 20 additions & 8 deletions source/Stellar/Download.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public partial class Download
//public static Thread worker = null;

// Web Downloads
public static WebClient wc = new WebClient();
public static WebClient wc2 = new WebClient();
//public static WebClient wc = new WebClient();
//public static WebClient wc2 = new WebClient();
public static ManualResetEvent waiter = new ManualResetEvent(false); // Download one at a time

public static string progressInfo; // Progress Label Info
Expand Down Expand Up @@ -150,6 +150,8 @@ public static void StartDownload(MainWindow mainwindow)
{
RetroArchDownload(mainwindow);
});
worker.IsBackground = true;


// Start Download Thread
//
Expand All @@ -170,6 +172,7 @@ public static void StartDownload(MainWindow mainwindow)
CoresDownload(mainwindow);
});
worker.IsBackground = true;

// Start Download Thread
//
Expand All @@ -187,6 +190,7 @@ public static void StartDownload(MainWindow mainwindow)
{
CoresDownload(mainwindow);
});
worker.IsBackground = true;

// Start Download Thread
//
Expand Down Expand Up @@ -217,6 +221,8 @@ public static void StartDownload(MainWindow mainwindow)
// -------------------------
public static void StellarDownload(MainWindow mainwindow)
{
WebClient wc = new WebClient();

// -------------------------
// Download
// -------------------------
Expand Down Expand Up @@ -337,6 +343,8 @@ public static void StellarDownload(MainWindow mainwindow)
// -------------------------
public static void RetroArchDownload(MainWindow mainwindow)
{
WebClient wc = new WebClient();

// -------------------------
// Download
// -------------------------
Expand All @@ -345,15 +353,17 @@ public static void RetroArchDownload(MainWindow mainwindow)
//waiter = new ManualResetEvent(false); //start a new waiter for next pass (clicking update again)
//});

ServicePointManager.Expect100Continue = true;
//ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

progressInfo = "Preparing Download...";

Uri downloadUrl = new Uri(Parse.nightlyUrl); // Parse.nightlyUrl = x84/x86_64 + Parse.nightly7z
//Uri downloadUrl = new Uri("http://127.0.0.1:8888/RetroArch.7z"); // TESTING Virtual Server URL

//Async
//wc.Headers.Add("User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");
wc.Headers.Add("Accept-Encoding", "gzip,deflate");
//wc.Headers.Add("Accept-Encoding", "gzip,deflate");
wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);
wc.DownloadFileCompleted += new AsyncCompletedEventHandler(wc_DownloadFileCompleted);
wc.DownloadFileAsync(downloadUrl, Paths.tempPath + Parse.nightly7z);
Expand Down Expand Up @@ -676,18 +686,20 @@ public static void CoresDownload(MainWindow mainwindow)
// -------------------------
for (int i = 0; i < Queue.List_UpdatedCores_Name.Count; i++) //problem core count & Parse.nightly7z
{
WebClient wc = new WebClient();

//Reset Waiter, Must be here
waiter.Reset();

ServicePointManager.Expect100Continue = true;
//ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

Uri downloadUrl2 = new Uri(Parse.parseCoresUrl + Queue.List_UpdatedCores_Name[i] + ".zip");
//Uri downloadUrl2 = new Uri("http://127.0.0.1:8888/latest/" + Queue.List_UpdatedCores_Name[i] + ".zip"); //TESTING
//Async
wc2.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);
wc2.DownloadFileCompleted += new AsyncCompletedEventHandler(wc_DownloadFileCompleted);
wc2.DownloadFileAsync(downloadUrl2, Paths.tempPath + Queue.List_UpdatedCores_Name[i] + ".zip", i);
wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);
wc.DownloadFileCompleted += new AsyncCompletedEventHandler(wc_DownloadFileCompleted);
wc.DownloadFileAsync(downloadUrl2, Paths.tempPath + Queue.List_UpdatedCores_Name[i] + ".zip", i);

// Progress Info
progressInfo = "Downloading " + Queue.List_UpdatedCores_Name[i];
Expand Down
10 changes: 10 additions & 0 deletions source/Stellar/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,10 @@ private void textBoxLocation_TextChanged(object sender, TextChangedEventArgs e)
// -----------------------------------------------
private void buttonCheck_Click(object sender, RoutedEventArgs e)
{
//Download.waiter.Reset();
//Download.waiter = new ManualResetEvent(false);


// Progress Info
textBlockProgressInfo.Text = "Checking...";

Expand Down Expand Up @@ -858,6 +862,9 @@ private void buttonUpdate_Click(object sender, RoutedEventArgs e)
|| (string)comboBoxDownload.SelectedItem == "RetroArch"
|| (string)comboBoxDownload.SelectedItem == "Redist")
{
// Progress Info
textBlockProgressInfo.Text = "Fetching RetroArch List...";

Parse.ParseBuildbotPage(this);
}

Expand Down Expand Up @@ -947,6 +954,9 @@ private void buttonUpdate_Click(object sender, RoutedEventArgs e)
|| (string)comboBoxDownload.SelectedItem == "Cores"
|| (string)comboBoxDownload.SelectedItem == "New Cores")
{
// Progress Info
textBlockProgressInfo.Text = "Fetching Cores List...";

// Create Builtbot Cores List
Parse.ParseBuildbotCoresIndex(this);

Expand Down
31 changes: 18 additions & 13 deletions source/Stellar/Parse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public static void ParseGitHubReleases(MainWindow mainwindow)
// GitHub ./version file
// Stellar Website Download Links

WebClient wc = new WebClient();

// -------------------------
// Update Selected
// -------------------------
Expand All @@ -98,7 +100,7 @@ public static void ParseGitHubReleases(MainWindow mainwindow)

try
{
parseLatestVersion = Download.wc.DownloadString("https://raw.githubusercontent.com/StellarUpdater/Stellar/master/.version");
parseLatestVersion = wc.DownloadString("https://raw.githubusercontent.com/StellarUpdater/Stellar/master/.version");
}
catch
{
Expand Down Expand Up @@ -194,22 +196,26 @@ public static void ParseBuildbotPage(MainWindow mainwindow)
MatchCollection matches = Regex.Matches(page, element);

if (matches.Count > 0)
{
foreach (Match m in matches)
{
Queue.NightliesList.Add(m.Groups[1].Value);
}

//MessageBox.Show("Matches found: {0}", string.Join(Environment.NewLine, matches.Count)); //debug

// Remove from the List all 7z files that do not contain _RetroArch.7z (filters out unwanted)
Queue.NightliesList.RemoveAll(u => !u.Contains("_RetroArch.7z"));
//MessageBox.Show("Matches found: {0}", string.Join(Environment.NewLine, matches.Count)); //debug

Queue.NightliesList.TrimExcess();
// Remove from the List all 7z files that do not contain _RetroArch.7z (filters out unwanted)
Queue.NightliesList.RemoveAll(u => !u.Contains("_RetroArch.7z"));

//var message = string.Join(Environment.NewLine, Queue.NightliesList); //debug
//MessageBox.Show(message);
Queue.NightliesList.TrimExcess();
}

// Sort the Nighlies List, lastest 7z is first
Queue.NightliesList.Sort(); //do not disable this sort

//var message = string.Join(Environment.NewLine, Queue.NightliesList); //debug
//MessageBox.Show(message);

// Get Lastest Element of Nightlies List
nightly7z = Queue.NightliesList.Last();
}
Expand Down Expand Up @@ -273,7 +279,6 @@ public static void ParseBuildbotPage(MainWindow mainwindow)

// Prevents Threading Crash
Download.waiter = new ManualResetEvent(false);
//Download.waiter.Reset();
}


Expand All @@ -283,7 +288,9 @@ public static void ParseBuildbotPage(MainWindow mainwindow)
// -----------------------------------------------
public static void ParseBuildbotCoresIndex(MainWindow mainwindow)
{
ServicePointManager.Expect100Continue = true;
WebClient wc = new WebClient();

//ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

// -------------------------
Expand All @@ -294,11 +301,9 @@ public static void ParseBuildbotCoresIndex(MainWindow mainwindow)

try
{
WebClient webclient = new WebClient();

// index-extended cores text file
//Download.webclient.Headers["Accept-Encoding"] = "gzip,deflate";
buildbotCoresIndex = webclient.DownloadString(indexextendedUrl);
buildbotCoresIndex = wc.DownloadString(indexextendedUrl);

// Trim ending linebreak
buildbotCoresIndex = buildbotCoresIndex.TrimEnd('\n');
Expand Down
4 changes: 2 additions & 2 deletions source/Stellar/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.8.7.0")]
[assembly: AssemblyFileVersion("0.8.7.0")]
[assembly: AssemblyVersion("0.8.7.1")]
[assembly: AssemblyFileVersion("0.8.7.1")]

0 comments on commit 95108ac

Please sign in to comment.