新版本更新了wx-downloader.js
引出了一个问题,我们原来的资源是手动下载放到微信usr目录下
但发现,还会重新去远程取一次,是因为readFromLocal只判断引擎自己是不是已经从远端取过,不像原来也会判断/usr下面有没文件
自己fix了一下,可以使用,代码如下,但每次发版本都需要修改,很麻烦,希望能修复
`function readFromLocal (item, callback) {
var result = wxFsUtils.checkFsValid();
if (result) {
callback(result);
return;
}
var cachedPath = wxDownloader.getCacheName(item.url);
var localPath = wxDownloader.cacheDir + '/' + cachedPath;
if (cachedPath in cachedFiles) {
// cache new asset
_newAssets[cachedPath] = true;
item.url = localPath;
registerFailHandler(item, cachedPath);
handleItem(item, callback);
}
else {
var localPath = wx.env.USER_DATA_PATH + '/' + item.url;
// Read from local file cache
fs.access({
path: localPath,
success: function () {
// cache new asset
_newAssets[cachedPath] = true;
item.url = localPath;
registerFailHandler(item, cachedPath);
handleItem(item, callback);
},
fail: function (res) {
if (!wxDownloader.REMOTE_SERVER_ROOT) {
callback(null, null);
return;
}
downloadRemoteFile(item, callback);
}
});
}
}`