Revadike / epicgames-freebies-claimer

Claim available free game promotions from the Epic Games Store.
MIT License
2.23k stars 360 forks source link

Auto-update #160

Open Revadike opened 2 years ago

Revadike commented 2 years ago

Current Behavior (if any)

Only notifies of new version.

Desired Behavior

Add a setting, such that epicgames-freebies-claimer will auto-update.

Motivation / Use Case for Changing the Behavior

If a breaking bug occurs, fixes can be automatically retrieved and operation can continue normally.

jackblk commented 2 years ago

Currently if user uses Docker image, it already has auto update via latest tag. Docker user will want to disable this option as default, but non-docker user will want it to be enabled as default.

If we use config file to disable/enable this option, it will cause a problem. Normally people will run the docker image without providing config.json file, so it will copy from the example config (enabled as default for non-docker user). Can be done, but not nice to use.

So in order to avoid conflict with docker users, I suggest that we have check for an environment variable like EFC_DISABLE_AUTO_UPDATE. If this env var is true, then we will disable auto update. This is very easy to config in Dockerfile, we will disable auto update module in Docker image as default.

If Docker user wants to have autoupdate, they can also override the env var. Win-win for docker or non-docker user.

Revadike commented 2 years ago

Maybe this latest tag can override the config value, if we can detect it somehow for docker.

jackblk commented 2 years ago

Hmm then maybe we can have both? EFC will check for the:

Something like: if (!process.env.EFC_DISABLE_AUTO_UPDATE && config.autoUpdateFlag)

This way, even if we use default config, we can still disable it on docker image via env var EFC_DISABLE_AUTO_UPDATE.

Revadike commented 2 years ago

Is it not safe to assume people with the latest tag want auto-update enabled?

jackblk commented 2 years ago

If user uses latest tag on docker, it will automatically update to new version when I publish the new version (docker behavior). So they don't need to check or use the auto update module. If user wants to use a specific version (v1.5.6 for example), then they want to pin the version and do not want to update.

My suggestion for EFC_DISABLE_AUTO_UPDATE env var is for the docker user convenience (they can use default config file and disable via env var, which is easy to do in docker). It will not affect normal user.

I hope this makes sense 🤔

Revadike commented 2 years ago

How about we just disable any auto-update features if the user uses docker, since they have their own system anyway?

jackblk commented 2 years ago

Yeah that's what I'm suggesting. And the easiest way to do it is via checking env var EFC_DISABLE_AUTO_UPDATE.

Revadike commented 2 years ago

https://github.com/sindresorhus/is-docker/blob/main/index.js maybe

jackblk commented 2 years ago

https://github.com/sindresorhus/is-docker/blob/main/index.js maybe

It just checks for docker env & group, just like what we are trying to do by checking env var EFC_DISABLE_AUTO_UPDATE.

if (!process.env.EFC_DISABLE_AUTO_UPDATE && config.autoUpdateFlag) is enough for us, only docker user will have that specific env var to disable autoupdate module.

ffuubarbuzz commented 2 years ago

My 5 cents: I'm using docker in DSM (Synology's OS) and it doesn't auto-update containers built with the latest tag, I'd need to download new image and reset the container manually. Some other containers I run do auto-update the software they run inside and I find it extremely useful!