void Refresh() { enableLatest = E.i.showMode != 0; MakeDownloadList(); ReadWebResponseToFile(enableLatest); indexChanged = true; Helper.s_manifestJsonCache = null; RequestStatus.Reset(); }
public void DownloadFile(string url, string name, string repoName, string tag, string extention = "") { if (RequestStatus.networking) { EditorUtility.DisplayDialog("Warning", "No new downloads can be added during download", "OK"); return; } var outputDirectory = $"{E.gitHubCacheDirectory}/{name}/{repoName}/{tag}"; if (!Directory.Exists(outputDirectory)) { Directory.CreateDirectory(outputDirectory); } try { string fname; if (string.IsNullOrEmpty(extention)) { fname = GetFileName(url); } else { fname = $"{repoName}-{tag}{extention}"; } //System.Threading.Thread.Sleep( 10000 ); using (WebClient wc = new WebClient()) { RequestStatus.Begin($"Download File {GetFileName( url )}"); wc.Headers.Add("User-Agent", "Nothing"); wc.DownloadProgressChanged += (sender, e) => { RequestStatus.networkingMsg = $"Download File {GetFileName( url )} {e.ProgressPercentage} %"; }; wc.DownloadFileCompleted += (sender, e) => { RequestStatus.End(); MakeDownloadList(); Repaint(); }; wc.DownloadFileAsync(new Uri(url), outputDirectory + "/" + fname); } } catch (Exception e) { Debug.LogException(e); RequestStatus.SetError(e); } }