mirror of
https://github.com/Leo501/CocosCreatorTutorial.git
synced 2026-06-02 07:29:34 +08:00
添加当热更新失败后,退出游戏。当再次进入游戏时,清除临时文件
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user