cordova-app-updater icon indicating copy to clipboard operation
cordova-app-updater copied to clipboard

Handling missed updates

Open khamaileon opened this issue 8 years ago • 10 comments

What happens if a user misses an update? How the updater will know which files to download?

khamaileon avatar Sep 01 '16 12:09 khamaileon

User can miss update only if you set 'tryupdate' or 'cached' mode.

Nothing happens, user just use a old version.

About files to update - my goal in this plugin is keep it very simple. On every app startup plugin download config.json from server. All times whenever a config.json version in 'cached' folder is not equal to version download from server plugin will make those steps:

  • Create 'cached2' folder in cache.
  • Copy all files from apk www to 'cached2';
  • Download all files specified in config.json
  • If all previous steps successful - replace 'cache' folder with 'cache2', and redirect app into 'cache' folder. If in previous steps occurred an error - plugin goes to step 1 if policy is 'mustupdate' or don't replace cached folder and redirect user to old 'cahce' if policy 'tryupdate'.

Are my explain is clear for understand?

mnill avatar Sep 01 '16 12:09 mnill

Even if you set 'mustupdate' mode, the user can miss an update. For example if a user doesn't start the app for one week and during this time there are 2 updates. Different files in the second update is not necessarily the same as in the first.

khamaileon avatar Sep 01 '16 12:09 khamaileon

As I explained, all updates has its own life and don't associated with any other.

At any update user delete all previous updates and copy files from original 'www' folder (without any updates) to cache, and then download all files specified in latest config.json

All is simple - all you updates must be compatible with original build which uploaded to appstore\goolge play.

mnill avatar Sep 01 '16 12:09 mnill

I meant your latest update just must be compatible with version uploaded to store.

mnill avatar Sep 01 '16 13:09 mnill

Ok so I have to keep in mind that the reference is the latest version on the store.

Shouldn't it be more robust and efficient to keep hash of every file and update only the modified one?

khamaileon avatar Sep 01 '16 13:09 khamaileon

Efficient may be, but why is more robust with hash? I just want to keep it very simplified and free of bugs.

With my model there is very simple state machine in updater mechanism. We test it in production in really big apps and all works fine.

mnill avatar Sep 01 '16 14:09 mnill

How can you be sure your user has the latest version on the store before updating?

khamaileon avatar Sep 01 '16 14:09 khamaileon

I have different $SERVER_URL for every build.

After every new version I stop to update previous version and ask users to update the app if necessary.

Anyway if you updated the app it is means they have broken changes in plugins, right? What also may be a reason to update the app in the store if we have this beautiful updater :-)

mnill avatar Sep 01 '16 14:09 mnill

Different $SERVER_URL is a good tip thank you. How do you keep the list of modified files up to date?

khamaileon avatar Sep 01 '16 14:09 khamaileon

I just have a grunt script to build app.min.js and hardcoded list of changed imges\other files. Also this script create new config.json and upload files to server.

mnill avatar Sep 01 '16 14:09 mnill