Wedge

Public area => The Pub => Features => Topic started by: Nao on January 31st, 2014, 10:12 PM

Title: On the desirability of automatic updates..?
Post by: Nao on January 31st, 2014, 10:12 PM
In reply to:
http://wedge.org/pub/bugs/8393/errors-when-checking-detailed-version-info/msg293427/#msg293427

Believe it or not, it's actually in my plans... :P

However, it might require some time.
Remember when Aeva used to update its sitelist by itself every day..? Well, for a long time I've had the same idea in mind for Wedge, but with technical difficulties (notably the amount of bandwidth needed to account for version checks.)
When I heard of Github Releases, I figured, is it possible to get a URL to these files, directly..? And yes, it is. By using their well-documented API, one can do up to 60 requests per hour (or 5000 if you provide an ID token) from a certain IP, so it's a piece of cake for Github to 'accept' a daily request from even thousands of different servers, checking whether a new release was posted.
If a release is available, I can then get the URL to the zip or tarball, and then proceed to warn the user about it. Should they choose not to ignore the update, they could press a button to automatically download it to the server, and optionally (if supported), unzip it somewhere. Then, if that works, either apply the files automatically (move from tmp folder to core, assets, etc.), or offer the user to log into their site by FTP, and move the files they want to move.

Technical problems:
- This doesn't account for deleted files... But the automatic upgrade script could account for these, though, and make sure to try and delete them, if they can be harmful to Wedge.
- I don't know much about unzipping tarballs. I think there are plenty of functions for that kind of action available in Wedge, though...
- What if the automatic update process fails? Will it break a forum..?
- What if users don't have correct PHP file permissions for unzipping, etc..?
Title: Re: On the desirability of automatic updates..?
Post by: MultiformeIngegno on January 31st, 2014, 11:27 PM
Shouldn't I deserve at least a like on my post? :P
Take a look at this! I use it to automatically update the WordPress theme I create and mantain on GitHub: https://github.com/afragen/github-updater
Title: Re: On the desirability of automatic updates..?
Post by: Nao on February 1st, 2014, 12:06 AM
I'll like your other post, not this one, because it's a GPL codebase and I can't even have a glance at it without being accused of license breach... :lol:
Title: Re: On the desirability of automatic updates..?
Post by: MultiformeIngegno on February 1st, 2014, 12:18 AM
Quote from Nao on February 1st, 2014, 12:06 AM
I'll like your other post, not this one, because it's a GPL codebase and I can't even have a glance at it without being accused of license breach... :lol:
Ok but you could at least take inspiration on how he did things... :whistle: :P
Title: Re: On the desirability of automatic updates..?
Post by: Nao on February 1st, 2014, 12:43 AM
I know how to use the GitHub API... This is how commits get posted here automatically. The only reason I'd look into someone else's code is if I can't find time to write stuff myself. Otherwise, I usually find that writing the base code is usually the most enjoyable part... ;)
Title: Re: On the desirability of automatic updates..?
Post by: Nao on February 3rd, 2014, 07:12 PM
Bump for the first post!
Title: Re: On the desirability of automatic updates..?
Post by: MultiformeIngegno on February 3rd, 2014, 07:28 PM
Sorry if I say stupid things, I try :P
For the deleted files can't you just use the diff (I assume it's available in GitHub API) and if there are deleted files tell php to remove them. Then download the zip file from github, extract it (I think there shouldn't be any problem doing it with php..?) and replace old files (all the folder or just the ones modified, if diff file is available thought APIs). For permissions you can add a check. You first download the zip (if you don't have permissions simply it's not downloaded). Then you try to create a dummy empty file in the folder of the files the installer should replace. If it works you can proceed either removing all old files and putting new ones or just delete the ones that have been updated (from diff)..
Title: Re: On the desirability of automatic updates..?
Post by: Nao on February 3rd, 2014, 09:40 PM
Well, the idea is to make it as simple as possible, otherwise I won't even be arsed to start work on it... :^^;: