Commit 1d3e3bfb authored by Szefo09's avatar Szefo09

change to download from a fixed url each run

parent d9289f12
......@@ -480,65 +480,14 @@ public class Program : MonoBehaviour
{
try
{
WWW w = new WWW("https://api.github.com/repos/purerosefallen/ygopro-database-raw/contents/");
while (!w.isDone)
{
if (Application.internetReachability == NetworkReachability.NotReachable || !string.IsNullOrEmpty(w.error))
{
throw new Exception("No Internet connection!");
}
}
List<ApiFile> toDownload = new List<ApiFile>();
List<ApiFile> apiFromGit = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<List<ApiFile>>(w.text);
if (!File.Exists("updates/SHAs.txt"))
{
Directory.CreateDirectory("updates");
toDownload.AddRange(apiFromGit);
}
if (File.Exists("updates/SHAs.txt"))
{
List<ApiFile> local = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<List<ApiFile>>(File.ReadAllText("updates/SHAs.txt"));
foreach (ApiFile file in apiFromGit)
{
if (local.FirstOrDefault(x => x.name == file.name)==null || file.sha != local.FirstOrDefault(x => x.name == file.name).sha)
{
toDownload.Add(file);
}
}
foreach (ApiFile f in local)
{
if (apiFromGit.FirstOrDefault(x => x.name == f.name) == null || f.name != apiFromGit.FirstOrDefault(x => x.name == f.name).name)
{
if (File.Exists("cdb/" + f.name))
{
File.Delete("cdb/" + f.name);
}
if (File.Exists("config/" + f.name))
{
File.Delete("config/" + f.name);
}
}
}
}
HttpDldFile httpDldFile = new HttpDldFile();
foreach (var dl in toDownload)
{
if (Path.GetExtension(dl.name) == ".cdb" && !(Application.internetReachability == NetworkReachability.NotReachable))
{
httpDldFile.Download(dl.download_url, Path.Combine("cdb/", dl.name));
}
if (Path.GetExtension(dl.name) == ".conf" && !(Application.internetReachability == NetworkReachability.NotReachable))
{
httpDldFile.Download(dl.download_url, Path.Combine("config/", dl.name));
}
}
File.WriteAllText("updates/SHAs.txt", w.text);
httpDldFile.Download("http://koishi.222diy.gdn/ygopro/cards.cdb", Path.Combine("cdb /", "cards.cdb"));
httpDldFile.Download("http://koishi.222diy.gdn/ygopro/lflist.conf", Path.Combine("config /", "lflist.conf"));
httpDldFile.Download("http://koishi.222diy.gdn/ygopro/strings.conf", Path.Combine("config /", "strings.conf"));
}
catch (Exception e)
{
File.Delete("updates/SHAs.txt");
Debug.Log("UPDATE ERROR: " + e.ToString());
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment