Hot Update content size

Hot Update content size

Hellow everyone.

How can I get the size of the content to be downloaded on hot update, before it starts?

AFAIK the hole update size is only available after the assetmanager.update() function, that will start download things, but Apple is refusing my app because it has to have this info before.

Pack your hotupdate contents into a single zip file. So your total download size is the size of that zip file.

Or when you produce mainfest, you can add up sizes of the files and save it as an attribute of the mainfest. Then you can make the size known to user before download.

1 Like

For a single zip file, it will against the hot update logic, that you can download only the files that are different from your version, and I need that behavior.

About the manifest have a file size, it already has, but it seems that I will have to make a function about this, while, in thesis, cocos should send me this info.

Looking in cocos source code, in .\resources\cocos2d-x\extensions\assets-manager\AssetsManagerEx.h it has this line of code

/** @brief Gets the total byte size to be downloaded of the update, this will only be available after READY_TO_UPDATE state, under unknown states it will return 0 by default. */ double getTotalBytes() const {return _totalSize;};

So, first I have to make it READY_TO_UPDATE. OK, looking in the cpp file, prepareUpdate() should do the trick, but it continues giving me size 0, and now neither update() or startUpdate() works anymore.

So, now that the cocos native process is not working, I have to make my own instead :slightly_frowning_face::disappointed:

You can’t measure the total file size from client side before files are downloaded.
For that, you should manually read the mainfest file and calculate total file size (loop the assets and add up their sizes).

So, I think, a better approach would be to get this done from server side.
When you produce mainfest file (I think, using Node.JS?), you should produce the total size.
Then add it as an attribute in mainfest and read that attribute value from client side and just display it.