1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[pollock] fix a sequential download issue

* Apparently you need to close the request/response as the Garbage Collection
  will not do that for you. High level language my ass!
This commit is contained in:
Pete Batard 2018-07-15 00:20:13 +01:00
parent d9d0feadb6
commit 1014b8008d
2 changed files with 13 additions and 11 deletions

View file

@ -114,7 +114,6 @@ namespace pollock
private static Encoding encoding = new UTF8Encoding(false);
private static List<string> rtl_languages = new List<string> { "ar-SA", "he-IL", "fa-IR" };
private static Stopwatch sw = new System.Diagnostics.Stopwatch();
private static WebClient wc = new WebClient();
private static DateTime last_changed = DateTime.MinValue;
private static int download_status;
private static int console_x_pos;
@ -726,12 +725,15 @@ namespace pollock
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
status = response.StatusCode;
response.Close();
}
catch (WebException we)
{
HttpWebResponse response = we.Response as HttpWebResponse;
status = response.StatusCode;
response.Close();
}
request.Abort();
switch (status)
{
case HttpStatusCode.OK:
@ -754,7 +756,7 @@ namespace pollock
if (!ValidateDownload(url))
return null;
using (wc)
using (WebClient wc = new WebClient())
{
try
{
@ -789,7 +791,7 @@ namespace pollock
return false;
console_x_pos = Console.CursorLeft;
using (wc)
using (WebClient wc = new WebClient())
{
wc.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
wc.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadCompleted);
@ -823,13 +825,13 @@ namespace pollock
{
if (cancel_requested)
{
wc.CancelAsync();
((WebClient)sender).CancelAsync();
return;
}
if (in_progress)
return;
// Prevent this call from being re-entrant
if (in_progress)
return;
in_progress = true;
speed = (e.BytesReceived / 1024d / sw.Elapsed.TotalSeconds);

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 3.2.1336"
CAPTION "Rufus 3.2.1337"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -392,8 +392,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,2,1336,0
PRODUCTVERSION 3,2,1336,0
FILEVERSION 3,2,1337,0
PRODUCTVERSION 3,2,1337,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -411,13 +411,13 @@ BEGIN
VALUE "Comments", "https://akeo.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.2.1336"
VALUE "FileVersion", "3.2.1337"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus-3.2.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.2.1336"
VALUE "ProductVersion", "3.2.1337"
END
END
BLOCK "VarFileInfo"