diff --git a/BaiduPanDownload/Forms/AddDownload.cs b/BaiduPanDownload/Forms/AddDownload.cs index d0bd05c..26bbb52 100644 --- a/BaiduPanDownload/Forms/AddDownload.cs +++ b/BaiduPanDownload/Forms/AddDownload.cs @@ -95,7 +95,7 @@ void AddDownloadButton() this.button2.Text = "添加下载"; return; } - if (info.size <= Program.config.NetSpeed) + if (info.size <= Program.config.NetSpeed && info.isdir!=1) { MessageBox.Show("文件太小,无法下载!"); this.button2.Enabled = true; diff --git a/BaiduPanDownload/Forms/Login.cs b/BaiduPanDownload/Forms/Login.cs index 4a65157..72da7ba 100644 --- a/BaiduPanDownload/Forms/Login.cs +++ b/BaiduPanDownload/Forms/Login.cs @@ -38,6 +38,11 @@ private void Login_Load(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e) { Regex rg = new Regex("(?<=(" + "access_token=" + "))[.\\s\\S]*?(?=(" + "&" + "))", RegexOptions.Multiline | RegexOptions.Singleline); + if (webBrowser1.Url == null) + { + MessageBox.Show("尚未加载完成!"); + return; + } string token = rg.Match(webBrowser1.Url.ToString()).Value; if (token == string.Empty) { diff --git a/BaiduPanDownload/Forms/Main.Designer.cs b/BaiduPanDownload/Forms/Main.Designer.cs index 103d812..50292bc 100644 --- a/BaiduPanDownload/Forms/Main.Designer.cs +++ b/BaiduPanDownload/Forms/Main.Designer.cs @@ -342,11 +342,11 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this.label1.AutoSize = true; this.label1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label1.Location = new System.Drawing.Point(44, 10); + this.label1.Location = new System.Drawing.Point(12, 11); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(601, 19); + this.label1.Size = new System.Drawing.Size(658, 19); this.label1.TabIndex = 1; - this.label1.Text = "注意:百度更新后已限速,使用高速下载能在一定程度上提速(双击高速下载的任务可进入查看详情)"; + this.label1.Text = "注意:百度更新后已限速,使用软件自带的下载能在一定程度上提速,如果下载到99+后0K/S请尝试暂停重试"; // // DownloadListView // diff --git a/BaiduPanDownload/Forms/Main.cs b/BaiduPanDownload/Forms/Main.cs index 8ea88d4..3f45e88 100644 --- a/BaiduPanDownload/Forms/Main.cs +++ b/BaiduPanDownload/Forms/Main.cs @@ -247,8 +247,8 @@ void Upgraded() try { JObject job = JObject.Parse(WebTool.GetHtml("http://www.mrs4s.top/api/update.json")); - //版本7 - if ((int)job["Build"] > 7) + //版本8 + if ((int)job["Build"] > 8) { DialogResult dr = MessageBox.Show((string)job["Message"] + "\r\n\r\n是否更新?", "发现更新", MessageBoxButtons.OKCancel); if (dr == DialogResult.OK) @@ -379,13 +379,13 @@ private void UpdateDownLoadList_Timer_Tick(object sender, EventArgs e) item.SubItems.Add(Task.DownloadPath); item.SubItems.Add((getSizeMB((long)Task.Speed) < 1 ? (Task.Speed / 1024) + "K/s" : getSizeMB((long)Task.Speed) + "M/s")); item.SubItems.Add(Task.Percentage + "%"); - item.SubItems.Add(Task.Downloading?"下载中":"停止中"); + item.SubItems.Add(Task.Downloading?"下载中":Task.Completed?"下载完成":"暂停中"); 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[5].Text = Task.Downloading ? "下载中" : "停止中"; + DownloadListView.Items[Task.ID].SubItems[5].Text = Task.Downloading ? "下载中" : Task.Completed ? "下载完成" : "暂停中"; } DownloadListView.EndUpdate(); return; diff --git a/BaiduPanDownload/HttpTool/Download/DownloadThread.cs b/BaiduPanDownload/HttpTool/Download/DownloadThread.cs index e276b4b..67d84ae 100644 --- a/BaiduPanDownload/HttpTool/Download/DownloadThread.cs +++ b/BaiduPanDownload/HttpTool/Download/DownloadThread.cs @@ -44,7 +44,7 @@ public DownloadThread() Thread WorkThread; HttpWebRequest Request; - + HttpWebResponse Response; public void Start() { try @@ -57,7 +57,7 @@ public void Start() } Request = WebRequest.Create(DownloadUrl) as HttpWebRequest; Request.AddRange(Block.From,Block.To); - HttpWebResponse Response = Request.GetResponse() as HttpWebResponse; + Response = Request.GetResponse() as HttpWebResponse; if (!File.Exists(Path)) { Console.WriteLine("出现错误: 本地数据文件不存在"); @@ -106,8 +106,9 @@ public void Stop() { return; } - WorkThread.Abort(); Request?.Abort(); + Response?.Close(); + WorkThread.Abort(); } } } diff --git a/BaiduPanDownload/HttpTool/Download/HttpDownload.cs b/BaiduPanDownload/HttpTool/Download/HttpDownload.cs index 76fc4fd..afa76e8 100644 --- a/BaiduPanDownload/HttpTool/Download/HttpDownload.cs +++ b/BaiduPanDownload/HttpTool/Download/HttpDownload.cs @@ -186,12 +186,13 @@ public void StopAndSave() { if (Threads != null) { - foreach(var Thread in Threads) + Downloading = false; + Stoped = true; + CompletedThread = 0; + foreach (var Thread in Threads) { Thread.Stop(); } - Stoped = true; - Downloading = false; Info.Save(DownloadPath + ".dcj"); } } diff --git a/BaiduPanDownload/Managers/TaskManager.cs b/BaiduPanDownload/Managers/TaskManager.cs index 8e07eaf..71d9e3b 100644 --- a/BaiduPanDownload/Managers/TaskManager.cs +++ b/BaiduPanDownload/Managers/TaskManager.cs @@ -40,9 +40,14 @@ public TaskManager() public event onTaskReloadEvent ReloadEvnet; #endregion + bool Flag = false; private void TaskManagerTimer_Elapsed(object sender, ElapsedEventArgs e) { + if (Flag) + { + return; + } if (GetDwonloadingTaskNum() < Program.config.TaskNum) { var WaitTask = TaskList.Where(v=> (!v.Value.Completed && !v.Value.Downloading && !v.Value.Stoped)); @@ -66,6 +71,7 @@ public void CreateDownloadTask(string DownloadUrl,string DownloadPath) { return; } + Flag = true; var Task=new HttpDownload { ID=TaskList.Count, @@ -76,6 +82,7 @@ public void CreateDownloadTask(string DownloadUrl,string DownloadPath) Task.CreateDataFile(); Program.config.SetDownloadInfo(DownloadPath+".dcj",false); TaskList.Add(TaskList.Count,Task); + Flag = false; } ///