def _check_version(self): """Actually check for an auto-update: 1. Check the version number from the file on the version site. 2. Check the stable version number from the file on the version site. 3. Notify the user and stop if they are on an OS with no installer. 4. Get the torrent file from the version site. 5. Get the signature from the version site. 6. Check the signature against the torrent file using the public key. 7a. Start the torrent if it's not in the client. 7b. Restart the torrent if it's in the client but not running. 8. Put the infohash of the torrent into estate so the butler knows to butle it. 9. AutoUpdateButler.started() ensures that only the most recent auto-update torrent is running. 10. AutoUpdateButler.finished() indicates the new version is available, the UI polls for that value later. Whether an auto-update was found and started or not, requeue the call to check_version() to run a day later. This means that the version check runs at startup, and once a day. """ debug_prefix = '_check_version() run#%d: '%self.runs self.debug(debug_prefix + 'starting') url = self.version_site + self.current_version.name() df = ThreadedDeferred(_wrap_task(self.rawserver.external_add_task), self._get_available, url, daemon=True) yield df try: available_version = df.getResult() except BTFailure, e: self.debug(debug_prefix + 'failed to load %s' % url) self._restart() return
available_version = df.getResult() except BTFailure, e: self.debug(debug_prefix + 'failed to load %s' % url) self._restart() return if available_version.is_beta(): if available_version[1] != self.current_version[1]: available_version = self.current_version if self.current_version.is_beta(): stable_url = self.version_site + 'stable' df = ThreadedDeferred(_wrap_task(self.rawserver.external_add_task), self._get_available, stable_url) yield df try: available_stable_version = df.getResult() except BTFailure, e: self.debug(debug_prefix + 'failed to load %s' % url) self._restart() return if available_stable_version > available_version: available_version = available_stable_version self.debug(debug_prefix + 'got %s' % str(available_version)) if available_version <= self.current_version: self.debug(debug_prefix + 'not updating old version %s' % str(available_version)) self._restart() return