JoeGandy / ShareX-Custom-Upload

A little PHP script created for uploading custom sharex files to your own webserver
MIT License
166 stars 50 forks source link

Add automatic updater #99

Closed theaquarium closed 4 years ago

theaquarium commented 4 years ago

Resolves #95

This adds automatic updating functionality exactly as described in the linked issue. All a user has to do to update is copy the release folder to their site, click a button, and voila! However, this script doesn't modify user configuration, so it shouldn't break any installs. That also means that users will need to manually edit the configuration if the config schema changes in the future.

theaquarium commented 4 years ago

Ok, so now I've rewritten the updater so that you don't need to manually download the new update anymore. The uploader now will check GitHub for new versions and if it detects one, it will prompt to update. If the user agrees, the new update is downloaded, unzipped, and installed.

Users have the option of completely disabling the updater, as well as making a backup of the updated files. The backup option is on by default and just copies the old versions of files that get updated into another folder so that users can easily roll back to an older version.

Users will still need to manually update any configuration schema changes, but the uploader asks users to please read the changelog twice before the update starts.

This is meant to really streamline the update process so that users really don't have to think about updates and so that we can push crucial updates if we need to, but if users want to run their uploader without being affected by any changes we make, they can just turn updates off.

Let me know what you think.

davwheat commented 4 years ago

I think that we should add a form of Migration system where, in the case of config schema changes, we can run a set of migrations which update the config. The issue is that it would be difficult to parse the config.

theaquarium commented 4 years ago

That's fair. This would be pretty easy to add if config options are added, but not if any are removed. Maybe it could work by looping through the new config and checking if each option exists in the old config and if it doesn't copying the value (which would be the default value) over. Then, users could look through and see what they need to change. Writing the config back into the file would be extremely challenging though. I think the best way to go around this is to just use JSON config, but it might be too late for that.

theaquarium commented 4 years ago

Another proposition, instead of actually changing the config, we can have a default config file which is used whenever a config option is unavailable. This way, we don't touch the user's config at all and they can go and change their config on their own later. To help with this, maybe the uploader could show a little banner which lists which options the default config is being used for so that the users know what they need to add.

theaquarium commented 4 years ago

Alright, I've implemented it basically as I described in the second comment. All files now load config from merge_config.php instead of config.php. The merge_config.php file combines user config with default config and makes note of all missing options. Then, the list of missing options is displayed on the gallery page like so:

image

I think this is a pretty good way to notify users of errors like this without having to touch their config. Let me know what you think.

theaquarium commented 4 years ago

There, that should have fixed it.

JoeGandy commented 4 years ago

Sorry for the delay in approving! Looks great