Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Commit

Permalink
修复了一处可能导致下载无速度的bug,修改了一处文字显示
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrs4s committed Nov 24, 2016
1 parent 8e7df9c commit 5119213
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
7 changes: 4 additions & 3 deletions BaiduPanDownload/Forms/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ void updateFileList(object path)
try
{
Path_Lab.Text = "当前路径:" + path.ToString().Replace("apps", "我的应用数据");
var a = WebTool.GetHtml($"https://pcs.baidu.com/rest/2.0/pcs/file?method=list&access_token={Program.config.Access_Token}&path=" + Uri.EscapeDataString($"{path.ToString()}"));
var jobj = JObject.Parse(WebTool.GetHtml($"https://pcs.baidu.com/rest/2.0/pcs/file?method=list&access_token={Program.config.Access_Token}&path="+ Uri.EscapeDataString($"{path.ToString()}")));
FilelistView.BeginUpdate();
FilelistView.Items.Clear();
Expand Down Expand Up @@ -212,7 +213,7 @@ private void Blog_Link_LinkClicked(object sender, LinkLabelLinkClickedEventArgs

private void Main_Load(object sender, EventArgs e)
{
System.Net.ServicePointManager.DefaultConnectionLimit = 99999;
System.Net.ServicePointManager.DefaultConnectionLimit = 999999;
if (!Directory.Exists(Program.config.TempPath))
{
Directory.CreateDirectory(Program.config.TempPath);
Expand Down Expand Up @@ -385,8 +386,8 @@ private void UpdateDownLoadList_Timer_Tick(object sender, EventArgs e)
DownloadListView.Items.Add(item);
continue;
}
DownloadListView.Items[Task.ID].SubItems[3].Text = (getSizeMB((long)Task.Speed) < 1 ? (Task.Speed / 1024) + "K/s" : getSizeMB((long)Task.Speed) + "M/s");
DownloadListView.Items[Task.ID].SubItems[4].Text = Task.Percentage + "%";
DownloadListView.Items[Task.ID].SubItems[3].Text = Task.Completed ? "0K/S" : (getSizeMB((long)Task.Speed) < 1 ? (Task.Speed / 1024) + "K/s" : getSizeMB((long)Task.Speed) + "M/s");
DownloadListView.Items[Task.ID].SubItems[4].Text = Task.Completed?"100%":Task.Percentage + "%";
DownloadListView.Items[Task.ID].SubItems[5].Text = Task.Downloading ? "下载中" : Task.Completed ? "下载完成" : "暂停中";
}
DownloadListView.EndUpdate();
Expand Down
11 changes: 9 additions & 2 deletions BaiduPanDownload/HttpTool/Download/DownloadThread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public DownloadThread()
WorkThread=new Thread(Start);
WorkThread.Start();
}

int num=0;
Thread WorkThread;
HttpWebRequest Request;
HttpWebResponse Response;
Expand All @@ -56,6 +56,7 @@ public void Start()
return;
}
Request = WebRequest.Create(DownloadUrl) as HttpWebRequest;
Request.Timeout = 5000;
Request.AddRange(Block.From,Block.To);
Response = Request.GetResponse() as HttpWebResponse;
if (!File.Exists(Path))
Expand All @@ -68,7 +69,7 @@ public void Start()
using (FileStream Stream=new FileStream(Path,FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
{
Stream.Seek(Block.From, SeekOrigin.Begin);
byte[] Array = new byte[1024];
byte[] Array = new byte[4096];
int i = ResponseStream.Read(Array, 0, Array.Length);
while (i > 0)
{
Expand All @@ -94,6 +95,12 @@ public void Start()
{
return;
}
if (num < 5)
{
num++;
Console.WriteLine("出现错误: " + ex.ToString()+"正在重试 次数"+num);
Start();
}
Console.WriteLine("出现错误: "+ex.ToString());
}
}
Expand Down
4 changes: 2 additions & 2 deletions BaiduPanDownload/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.7.5.0")]
[assembly: AssemblyFileVersion("1.7.5.0")]
[assembly: AssemblyVersion("1.7.6.0")]
[assembly: AssemblyFileVersion("1.7.6.0")]

0 comments on commit 5119213

Please sign in to comment.