Beispiel #1
0
 public Md5File(string module, string removeText)
 {
     _module        = module;
     _version       = VersionHelp.version;
     _localMd5Dict  = Md5FileHelp.LocalFileForDict(_module, "md5file.txt");
     _remoteMd5Dict = Md5FileHelp.ForDict(removeText);
     _tmpMd5Dict    = Md5FileHelp.LocalFileForDict(_module, "tmp.txt");
     _downloadQueue = new Queue <SDownloadModuleConfig>();
     InitUpdateFile();
 }
        private void DownloadCompleted(WWW www)
        {
            if (www == null)
            {
                if (failCount == GameConfig.download_Fail_Count)
                {
                    if (callback != null)
                    {
                        callback(null);
                    }
                    return;
                }
                Download(GameConfig.download_Fail_Retry_Delay);
                failCount++;
                return;
            }

            localMd5Dict  = Md5FileHelp.LocalFileForDict(module);
            remoteMd5Dict = Md5FileHelp.ForDict(www.text);
            Dictionary <string, string> .Enumerator e = remoteMd5Dict.GetEnumerator();
            Queue <DownloadConfig> DownloadList       = new Queue <DownloadConfig>();

            while (e.MoveNext())
            {
                string md5 = null;
                localMd5Dict.TryGetValue(e.Current.Key, out md5);
                string file = string.Format("{0}/{1}", Util.DeviceResPath, e.Current.Key);
                if (md5 == null || md5.Trim() != e.Current.Value.Trim() || !File.Exists(file))
                {
                    DownloadConfig fileConfig = new DownloadConfig();
                    fileConfig.key           = e.Current.Key;
                    fileConfig.download_url  = string.Format("{0}/{1}/{2}", version.res_download_url, GameConfig.module_name, e.Current.Key);
                    fileConfig.localPath_url = string.Format("{0}/{1}", Util.DeviceResPath, e.Current.Key);
                    DownloadList.Enqueue(fileConfig);

                    if (!e.Current.Key.EndsWith(".txt"))
                    {
                        DownloadConfig manifestConfig = new DownloadConfig();
                        fileConfig.key = null;
                        manifestConfig.download_url  = string.Format("{0}.{1}", fileConfig.download_url, "manifest");
                        manifestConfig.localPath_url = string.Format("{0}.{1}", fileConfig.localPath_url, "manifest");
                        DownloadList.Enqueue(manifestConfig);
                    }
                }
            }
            e.Dispose();
            if (callback != null)
            {
                callback(DownloadList);
            }
        }