예제 #1
0
        /// <summary>
        /// 向服务器上传Bundle文件.
        /// </summary>
        private bool UpLoadFileToServer()
        {
            if (string.IsNullOrEmpty(this.UploadBaseUrl) == true)
            {
                return(false);
            }
            if (this._target == null)
            {
                return(false);
            }
            if (this._server == null)
            {
                return(false);
            }

            // 上传Bundle文件
            string uploadBundleUrl = string.Format("{0}/{1}", this.UploadBaseUrl, this.FileName);
            string inputFilePath   = UploadList.GetLocalBundleFilePath(
                this._target.ID, this._target.FileType, (TBundleType.Scene == this._target.BundleType));

            if (File.Exists(inputFilePath) == true)
            {
                if (this._onStart != null)
                {
                    this._onStart(this.FileName);
                }

                if (TUploadWay.Ftp == this._uploadWay)
                {
                    this._state = this.UpLoadFileToFtpServer(
                        uploadBundleUrl, inputFilePath, this._server.AccountId, this._server.Pwd);
                    if (TRunState.OK != this._state)
                    {
                        ErrorDetail error = new ErrorDetail();
                        error.Type   = TErrorType.UploadFailed;
                        error.State  = this._state;
                        error.Detail = string.Format("[Upload Failed] {0} -> {1}",
                                                     inputFilePath, uploadBundleUrl);
                        error.Retries = this.Retries;
                        this._errors.Add(error);
                        return(false);
                    }
                    else
                    {
                        if (this._onSuccessed != null)
                        {
                            this._onSuccessed(this, this._target, this.Retries);
                        }
                    }
                }
            }
            return(true);
        }
예제 #2
0
        /// <summary>
        /// 备份本地文件.
        /// </summary>
        private void BackUpBundleFiles()
        {
            foreach (UploadItem loop in UploadList.GetInstance().Targets)
            {
                string subDir = UploadList.AssetBundleDirNameOfNormal;
                if (TBundleType.Scene == loop.BundleType)
                {
                    subDir = UploadList.AssetBundleDirNameOfScenes;
                }

                string filePath = UploadList.GetLocalBundleFilePath(
                    loop.ID, loop.FileType, (TBundleType.Scene == loop.BundleType));
                string manifestFilePath = UploadList.GetLocalBundleFilePath(
                    loop.ID, loop.FileType, (TBundleType.Scene == loop.BundleType));

                // 废弃Bundle
                if (loop.Scraped == true)
                {
                    if (File.Exists(filePath) == true)
                    {
                        File.Delete(filePath);
                    }
                    if (File.Exists(manifestFilePath) == true)
                    {
                        File.Delete(manifestFilePath);
                    }
                }
                else
                {
                    // Bundle 文件备份
                    if (this.BackupFile(filePath, subDir) == false)
                    {
                        break;
                    }

                    // Bundle 文件备份
                    if (this.BackupFile(manifestFilePath, subDir) == false)
                    {
                        break;
                    }
                }
            }
        }