|
|
|
@ -1090,6 +1090,8 @@ def get_update_status():
|
|
|
|
|
'message': '',
|
|
|
|
|
'current_commit_hash': ''
|
|
|
|
|
}
|
|
|
|
|
parents = []
|
|
|
|
|
|
|
|
|
|
repository_url = 'https://api.github.com/repos/janeczku/calibre-web'
|
|
|
|
|
tz = datetime.timedelta(seconds=time.timezone if (time.localtime().tm_isdst == 0) else time.altzone)
|
|
|
|
|
|
|
|
|
@ -1098,7 +1100,7 @@ def get_update_status():
|
|
|
|
|
if version is False:
|
|
|
|
|
status['current_commit_hash'] = _(u'Unknown')
|
|
|
|
|
else:
|
|
|
|
|
status['current_commit_hash'] = version['sha']
|
|
|
|
|
status['current_commit_hash'] = version['hash']
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
r = requests.get(repository_url + '/git/refs/heads/master')
|
|
|
|
@ -1114,11 +1116,23 @@ def get_update_status():
|
|
|
|
|
status['message'] = _(u'General error')
|
|
|
|
|
|
|
|
|
|
if status['message'] != '':
|
|
|
|
|
status['success'] = False
|
|
|
|
|
return json.dumps(status)
|
|
|
|
|
|
|
|
|
|
if 'object' in commit and commit['object']['sha'] != status['current_commit_hash']:
|
|
|
|
|
if 'object' not in commit:
|
|
|
|
|
status['message'] = _(u'Unexpected data while reading update information')
|
|
|
|
|
return json.dumps(status)
|
|
|
|
|
|
|
|
|
|
if commit['object']['sha'] == status['current_commit_hash']:
|
|
|
|
|
status.update({
|
|
|
|
|
'update': False,
|
|
|
|
|
'success': True,
|
|
|
|
|
'message': _(u'Now update available. You already have the latest version installed')
|
|
|
|
|
})
|
|
|
|
|
return json.dumps(status)
|
|
|
|
|
|
|
|
|
|
# a new update is available
|
|
|
|
|
status['update'] = True
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
r = requests.get(repository_url + '/git/commits/' + commit['object']['sha'])
|
|
|
|
|
r.raise_for_status()
|
|
|
|
@ -1133,13 +1147,9 @@ def get_update_status():
|
|
|
|
|
status['error'] = _(u'General error')
|
|
|
|
|
|
|
|
|
|
if status['message'] != '':
|
|
|
|
|
status['success'] = False
|
|
|
|
|
return json.dumps(status)
|
|
|
|
|
|
|
|
|
|
if 'committer' in update_data and 'message' in update_data:
|
|
|
|
|
parents = []
|
|
|
|
|
|
|
|
|
|
status['update'] = True
|
|
|
|
|
status['success'] = True
|
|
|
|
|
status['message'] = _(u'A new update is available. Click on the button below update to the latest version.')
|
|
|
|
|
|
|
|
|
@ -1188,6 +1198,7 @@ def get_update_status():
|
|
|
|
|
else:
|
|
|
|
|
# parent is our current version
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
status['success'] = False
|
|
|
|
|
status['message'] = _(u'Could not fetch update information')
|
|
|
|
|