bool Download(string name, string md5, bool isHide, bool ignore_sound) { string file = Config.GetPath(name); if (ignore_sound && (name.EndsWith(".mp3", StringComparison.OrdinalIgnoreCase) || name.EndsWith(".ogg", StringComparison.OrdinalIgnoreCase) || name.EndsWith(".wav", StringComparison.OrdinalIgnoreCase))) //ignores sound { Console.WriteLine("SOUND IGNORED:" + name); showProcess(num++, all_num); return(true); } if (File.Exists(file)) { if (md5 == MyUtil.MD5_File(file)) //一致 { Console.WriteLine("SKIPPED:" + name); showProcess(num++, all_num); return(true); } else if (MyUtil.checkList(Config.ignores, name)) //忽略更新 { Console.WriteLine("IGNORED:" + name); showProcess(num++, all_num); return(true); } } //线程已满 while (MyHttp.NUM >= MyHttp.MAX_NUM) { //System.Threading.Thread.Sleep(100); } //下载文件 new MyHttp(Config.GetUrl(name), file, new fileinfo(name, md5)).Start(); return(true); //return MyHttp.DownLoad(url_download+name,file); }
public void Run(bool ignore_sound) { Console.WriteLine("UPDATE FROM:" + Config.url_home); Console.WriteLine("DOWNLOAD TO:" + Config.workPath); Console.WriteLine("CONFIG FILE:" + Assembly.GetExecutingAssembly().Location + ".config"); if (!File.Exists(Config.errorFile)) { Console.WriteLine("Getting New Version ... ..."); //version MyHttp.DownLoad(Config.url_version, Config.newVersionFile); //版本号一致 string md5_1 = MyUtil.MD5_File(Config.versionFile); string md5_2 = MyUtil.MD5_File(Config.newVersionFile); if (md5_1 == md5_2 && md5_1.Length > 0) { Console.WriteLine("Your files are already up-to-date."); return; } Console.WriteLine("New Version Discovered... ..."); //删除旧文件 Delete(); //重命名文件 Rename(); } Console.Clear(); //filelist Update(ignore_sound); if (File.Exists(Config.newVersionFile)) { File.Delete(Config.versionFile); File.Move(Config.newVersionFile, Config.versionFile); } Console.WriteLine("UPDATE COMPLETE!! You can safely close this window, press any key to quit."); }
bool Download(string name, string md5, bool isHide) { string file = Config.GetPath(name); if (File.Exists(file)) { if (md5 == MyUtil.MD5_File(file)) //一致 { Console.WriteLine("SKIPPED:" + name); showProcess(num++, all_num); return(true); } else { if (MyUtil.checkList(Config.ignores, name)) //忽略更新 { Console.WriteLine("IGNORED:" + name); showProcess(num++, all_num); return(true); } } } //线程已满 while (MyHttp.NUM >= MyHttp.MAX_NUM) { //System.Threading.Thread.Sleep(100); } //下载文件 new MyHttp(Config.GetUrl(name), file, new fileinfo(name, md5)).Start(); return(true); //return MyHttp.DownLoad(url_download+name,file); }
void AddFile(string file) { string filename = Path.GetFileName(file); string exename = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; if (filename.EndsWith("Thumbs.db", StringComparison.OrdinalIgnoreCase) || filename.EndsWith(".gitignore", StringComparison.OrdinalIgnoreCase) || filename.EndsWith("LICENSE", StringComparison.OrdinalIgnoreCase) || filename.EndsWith("appveyor.yml", StringComparison.OrdinalIgnoreCase) || filename.EndsWith(".travis.yml", StringComparison.OrdinalIgnoreCase) || filename.EndsWith("circle.yml", StringComparison.OrdinalIgnoreCase) || filename.EndsWith("README.md", StringComparison.OrdinalIgnoreCase) || filename.EndsWith("web.config", StringComparison.OrdinalIgnoreCase) || filename.EndsWith("update-server.bat", StringComparison.OrdinalIgnoreCase) || filename.EndsWith("desktop.ini", StringComparison.OrdinalIgnoreCase) || filename.EndsWith("start.htm", StringComparison.OrdinalIgnoreCase) || filename.EndsWith("update.exe.config", StringComparison.OrdinalIgnoreCase) || file == exename || file == exename + ".config" ) { return; } //处理名字 string name = file.Replace(Config.workPath, ""); name = name.Replace(Path.DirectorySeparatorChar, '/'); if (name.IndexOf('/') == 0) { name = name.Substring(1); } if (MyUtil.checkList(Config.ignores, name)) { return; } string md5 = MyUtil.MD5_File(file); if (!ci) { Console.WriteLine("FILE: "+ name); Console.WriteLine("MD5: " + md5); } list.Add(new fileinfo(name, md5)); }