*Creator 版本:2.0.8
-
目标平台: 华为快应用
-
重现方式:弱网测试偶尔会出现,反复loadResdir
-
编辑器操作系统 :android
rt-adapter.js 中 rt.downloadFile 不调用complete success fail中的任意一个,导致程序无法知道是否现在完成,目前只能设置一个超时时间,但无法预知是否下载正常。而且一旦触发这个错误,即使网络恢复正常并且重启快应用也无法再通知是否下载完成。由于没有回调导致本地缓存的功能缺失,每次重启都得重新下载。我自己已经没办法了,希望官方能帮忙看下
rt.downloadFile({
url: remoteUrl,
success: function (res) {
has_completed=true
console.log("=downloadFile success ",remoteUrl,Date.now()-begin_time)
//downloadSuccessCallback && downloadSuccessCallback();
if (res.statusCode === 404) {
cc.warn(“Download file failed: " + remoteUrl);
callback({
status: 0,
errorMessage: res && res.errMsg ? res.errMsg : “Download file failed: " + remoteUrl
});
}
else if (res.tempFilePath) {
// http reading is not cached
var localPath = rt.env.USER_DATA_PATH + ‘/’ + relatUrl;
console.log(”—>download success temp path : " + localPath);
// Save to local path
fs.saveFile({
tempFilePath: res.tempFilePath,
filePath: localPath,
success: function (res) {
cc.log(‘save:’ + localPath);
item.url = res.savedFilePath;
if (item.type && non_text_format.indexOf(item.type) !== -1) {
nextPipe(item, callback);
}
else {
readText(item, callback);
}
},
fail: function (res) {
// Failed to save file, then just use remote url
callback(null, null);
}
});
}
},
fail: function (res) {
console.log(”=downloadFile fail “,remoteUrl,Date.now()-begin_time)
has_completed=true
// Continue to try download with downloader, most probably will also fail
callback(null, null);
},
complete: function() {
console.log(”=downloadFile complete ",remoteUrl,Date.now()-begin_time)
has_completed=true
}
})
setTimeout(
function()
{
if (has_completed==false)
{
has_completed=true
console.log("=downloadFile timeout in rt-adapter.js ",remoteUrl)
callback(null,null);//{status: 0,errorMessage: "timeout"}
}
},
46000,
''
)