From 40280ac4e7cb34dd68b19d6bc8e24a8e40a9c08c Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 9 Apr 2019 00:27:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BD=93=E7=83=AD=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=A4=B1=E8=B4=A5=E5=90=8E=EF=BC=8C=E9=80=80=E5=87=BA?= =?UTF-8?q?=E6=B8=B8=E6=88=8F=E3=80=82=E5=BD=93=E5=86=8D=E6=AC=A1=E8=BF=9B?= =?UTF-8?q?=E5=85=A5=E6=B8=B8=E6=88=8F=E6=97=B6=EF=BC=8C=E6=B8=85=E9=99=A4?= =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HotUpdateDemo/assets/Script/HotUpdate.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/HotUpdateDemo/assets/Script/HotUpdate.js b/HotUpdateDemo/assets/Script/HotUpdate.js index 490ff8d..8e99f3f 100644 --- a/HotUpdateDemo/assets/Script/HotUpdate.js +++ b/HotUpdateDemo/assets/Script/HotUpdate.js @@ -29,6 +29,9 @@ cc.Class({ * @param {*} nextFn */ init(nextFn, progressFn, failedFn) { + //如果之前热更新失败。清除临时文件 + this.clearHotupdateCacheTemp(); + this.nextFn = nextFn; this.progressFn = progressFn; this.failedFn = failedFn; @@ -214,7 +217,7 @@ cc.Class({ console.log('ERROR_NO_LOCAL_MANIFEST'); break; case jsb.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST: - /*1下载配置文件错误*/ + /*1下载配置文件错误*/ case jsb.EventAssetsManager.ERROR_PARSE_MANIFEST: /*2 解析文件错误*/ console.log('ERROR_PARSE_MANIFEST'); @@ -256,7 +259,7 @@ cc.Class({ updateCb: function (event) { var needRestart = false; var failed = false; - var aleardyUpdate = false; + var aleardyUpdate = false; switch (event.getEventCode()) { case jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST: @@ -275,7 +278,7 @@ cc.Class({ case jsb.EventAssetsManager.ALREADY_UP_TO_DATE: // this.panel.info.string = 'Already up to date with the latest remote version.'; failed = true; - aleardyUpdate = true; + aleardyUpdate = true; break; case jsb.EventAssetsManager.UPDATE_FINISHED: // console.log('UPDATE_FINISHED'); @@ -297,7 +300,7 @@ cc.Class({ break; } - //下载失败 + //下载失败 if (failed) { // console.log('Hotupdate failure'); this.onFailure(ErrCode.updateFailed); @@ -321,12 +324,19 @@ cc.Class({ } }, - // + //清除热更新文件 clearHotupdateCache() { let storagePath = ((jsb.fileUtils ? jsb.fileUtils.getWritablePath() : '/') + this._hotUpdateName); jsb.fileUtils.removeDirectory(storagePath); }, + //清除临时热更新文件 + clearHotupdateCacheTemp() { + console.log('temp file clear'); + let storagePath = ((jsb.fileUtils ? jsb.fileUtils.getWritablePath() : '/') + this._hotUpdateName + '_temp'); + jsb.fileUtils.removeDirectory(storagePath); + }, + // update (dt) {}, onDestroy() {