void OnFinishedCallback(bool succ) { m_succesed = succ; if (m_succesed) { LogUtils.Log(m_name + " download succ!"); try { //todo...move or decrompress string desName = PathUtils.GetPersistentPath() + m_name; PathUtils.MakeSureDirExist(desName); if (File.Exists(desName)) { File.Delete(desName); } File.Copy(m_tempFile.GetTempFileName(), desName); m_tempFile.Delete(); //check if (m_signature.Length > 0) { bool vaild = FileChecker.VerifyFileSignature(desName, m_signature); if (vaild == false) { File.Delete(desName); LogUtils.LogError(m_name + " VerifyFileSignature faild!"); } m_succesed = vaild; } } catch (System.Exception ex) { m_succesed = false; LogUtils.LogError(ex.ToString()); } } else { LogUtils.LogError(m_name + " download faild!"); } m_status = DownLoadTaskStatus.Finished; }
public override void OnEnter(Status oldStatus) { LogUtils.Log("enter res file check and update status"); //check VersionRes verRes = VersionUpdate.GetIns().GetVersionRes(); DownloadMgr.GetInst().SetBaseURL(verRes.url); DownloadMgr.GetInst().SetMaxTaskNum(3); m_downloadFile.Clear(); m_downloadSuccFile.Clear(); for (int i = 0; i < verRes.versionResFile.Count; ++i) { VersionResFile resFile = verRes.versionResFile[i]; if (resFile.resType == VersionResType.PreDownload) { string fullPath = PathUtils.GetVaildFullPath(resFile.name); if (fullPath.Length == 0 || !FileChecker.VerifyFileSignature(fullPath, resFile.signature)) { m_downloadFile.Add(resFile.name); DownloadMgr.GetInst().CreateTask(resFile.name, verRes.versionResFile[i].signature, DownloadResult); } } else { string fileName = PathUtils.GetPersistentPath() + resFile.name; if (fileName.Length > 0 && File.Exists(fileName)) { if (!FileChecker.VerifyFileSignature(fileName, resFile.signature)) { File.Delete(fileName); } } } } CheckFinish(); }