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

385 adapter the taobaominigame ClearLRU procedure #17230

Merged
merged 14 commits into from
Jul 16, 2024
Merged

Conversation

tangkaikk
Copy link
Contributor

Re: #

Changelog

Fixes #17040 : taobao Platform can not trigger clearLRU

Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

1.taobao platform will clear tmp folder automatically.
2.when cachecount below 3, it will trigger LRU.
3.zip file, the path maybe is a zipfile.
Copy link

github-actions bot commented Jun 26, 2024

Interface Check Report

This pull request does not change any public interfaces !

return;
let clearCachCount = Math.floor(caches.length / 3);
// 大于3则清理1/3, 小于等于3则全部清理
if(clearCachCount > 3){
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use caches.length >= 12 instead of clearCacheCount > 3.

And below, you can use caches.length < 3 instead of clearCacheCount === 0.

This way, when caches.length < 3, you won't need to execute Math.floor(caches.length / 3).

可以使用 caches.length >= 12 代替 clearCacheCount > 3

下面可以使用 caches.length < 3 代替 clearCachCount === 0

这样可以使得当 caches.length < 3 时不用执行 Math.floor(caches.length / 3)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

change to :
if(caches.length < 3){
console.warn("Due to caching large files in the game, there is insufficient storage space. Now starting forced cleaning.");
}
else{
caches.length = Math.floor(caches.length / 3);
}

if (caches.length === 0) {
cleaning = false;
return;
// 大于3则清理1/3, 小于等于3则全部清理
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use english

Copy link
Contributor Author

Choose a reason for hiding this comment

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

have changed to English

cleaning = false;
return;
// cache length above 3 then clear 1/3, or clear all caches
if(caches.length < 3){
Copy link
Contributor

Choose a reason for hiding this comment

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

Please maintain the same JavaScript formatting style as the original code, including leaving a space after if or else.

请保持与原代码一样的 js 排版格式,if 或 else 后面保留一个空格

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code has been formatted.

@@ -23,14 +23,14 @@
THE SOFTWARE.
****************************************************************************/
const fs = my.getFileSystemManager ? my.getFileSystemManager() : null;
const outOfStorageRegExp = /the maximum size of the file storage/; // not exactly right
const outOfStorageRegExp = "10028"; // not exactly right
Copy link
Contributor

Choose a reason for hiding this comment

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

Why use string here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

taobao error code is "10028"

isOutOfStorage (errMsg) {
return outOfStorageRegExp.test(errMsg);
isOutOfStorage (errorCode) {
return errorCode.toString() == outOfStorageRegExp;
Copy link
Contributor

Choose a reason for hiding this comment

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

It is wired to compare string content to check out of storage.

Copy link
Contributor Author

@tangkaikk tangkaikk Jul 4, 2024

Choose a reason for hiding this comment

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

taobao use errorCode "10028" to judge out of storage.

Copy link
Contributor

Choose a reason for hiding this comment

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

What's the type of errorCode?

Copy link
Contributor Author

@tangkaikk tangkaikk Jul 4, 2024

Choose a reason for hiding this comment

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

normally it is string

Copy link
Contributor

Choose a reason for hiding this comment

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

If so, why need to change to string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In case of the error code in the other apis like donwloadFile or copyFile which will trigger LRU in the feature, will be not string type.

Copy link
Contributor

Choose a reason for hiding this comment

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

  • as the type is not fixed, so it is better to do some logic to make it more cearly
  • please use === instead
  • i think outOfStorageRegExp is not accurate, may be outOfStorageErrorCode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I has changed the code as what you suggested.

… more cearly

1.use === instead
2.the param name change tooutOfStorageErrorCode
# Conflicts:
#	platforms/minigame/common/engine/cache-manager.js
@minggo minggo merged commit bf4fcbe into cocos:v3.8.4 Jul 16, 2024
10 checks passed
minggo added a commit that referenced this pull request Jul 16, 2024
minggo added a commit that referenced this pull request Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

taobao Platform can not trigger clearLRU
4 participants