Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix hot update issue. #2312

Merged
merged 8 commits into from
Apr 22, 2020
2 changes: 1 addition & 1 deletion extensions/assets-manager/AssetsManagerEx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ void AssetsManagerEx::prepareUpdate()
std::string path = diff.asset.path;
DownloadUnit unit;
unit.customId = it->first;
unit.srcUrl = packageUrl + path;
unit.srcUrl = packageUrl + path + "?md5=" + diff.asset.md5;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

由于 md5 通常以 ‘==’ 结尾 或含有其他多义字符,是否encode更安全些

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

md5值是hex字符串,其计算方式是下面这样的,你是怎么遇到你描述的情况的,有测试工程吗?
crypto.createHash('md5').update(fs.readFileSync(subpath)).digest('hex');

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那没有问题了

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.cocos.com/creator/manual/zh/advanced-topics/assets-manager.html#manifest-%E6%A0%BC%E5%BC%8F

按照上述文档,

md5 信息可以不是文件的 md5 码,也可以是某个版本号,这完全是由用户决定的,本地和远程 manifest 对比时,只要 md5 信息不同,我们就认为这个文件有改动。

所以encode还是更安全的选择。

unit.storagePath = _tempStoragePath + path;
unit.size = diff.asset.size;
_downloadUnits.emplace(unit.customId, unit);
Expand Down