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() {