Example #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();
 }
Example #2
0
        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);
            }
        }
Example #3
0
        /// <summary>
        /// 退出时将md5写到文件
        /// </summary>
        public void Destroy()
        {
            string fullModule;

            if (_module != GameConfig.module_name)
            {
                fullModule = string.Format("{0}/{1}", Util.DeviceResPath, _module);
            }
            else
            {
                fullModule = Util.DeviceResPath;
            }
            Md5FileHelp.ForFile(_localMd5Dict, string.Format("{0}/{1}", fullModule, "md5file.txt"));
            Md5FileHelp.ForFile(_tmpMd5Dict, string.Format("{0}/{1}", fullModule, "tmp.txt"));
        }
Example #4
0
 public void WriteToLocalFile(string module)
 {
     Md5FileHelp.ForFile(localMd5Dict, module);
 }