Exemplo n.º 1
0
        private void PrepareDownloads(FileMapSystem.FileMapSystem newMap, string versionStr)
        {
            if (_downloader != null)
            {
                _downloader.Release();
                _downloader = null;
            }

            _downloader = new HttpFileDownloader(new Uri(GetDownloadBaseURL(versionStr)),
                                                 AssetBundlePathResolver.BundleSaveDirName);
            var currentMap = AssetBundleManager.Instance.GetFileMapSystem();
            var misses     = currentMap.GetMissFileMaps(newMap);

            _currentDownloadingGroupDesc = misses;
            CommonLog.Log(MAuthor.WY, $"{misses.Count} files miss in current file map");

            foreach (var fileMapGroupDescIter in misses)
            {
                var fileName     = fileMapGroupDescIter.Key;
                var desc         = fileMapGroupDescIter.Value;
                var fileSavePath = _savePath + fileName;

                if (File.Exists(fileSavePath))
                {
                    var bytes = FileUtils.ReadAllBytes(fileSavePath);
                    if (bytes != null && bytes.Length > 0)
                    {
                        var md5 = MD5Creater.Md5Struct(bytes);
                        if (md5.MD51 == desc.Md51 && md5.MD52 == desc.Md52)
                        {
                            CommonLog.Log(MAuthor.WY, $"file {fileSavePath} already exist, skip");
                            continue;
                        }
                    }
                }

                _downloader.AddDownLoad(new WWWFileDownloader.DownloadFileInfo
                {
                    FileName           = fileName,
                    FileSize           = desc.Len,
                    MapedFileName_MD51 = desc.Md51,
                    MapedFileName_MD52 = desc.Md52,
                });
            }
        }
Exemplo n.º 2
0
 private void OnApplicationQuit()
 {
     _downloader?.Release();
     _downloader = null;
 }