Updating improvement

pull/26/head
Louis Vézina 7 years ago
parent 200b6e0a76
commit ee9ef5e790

@ -302,7 +302,8 @@ def save_settings():
def check_update():
ref = request.environ['HTTP_REFERER']
check_and_apply_update()
result = check_and_apply_update()
logging.info(result)
redirect(ref)

@ -15,13 +15,17 @@ def check_and_apply_update(repo=local_repo, remote_name='origin'):
merge_result, _ = repo.merge_analysis(remote_id)
# Up to date, do nothing
if merge_result & pygit2.GIT_MERGE_ANALYSIS_UP_TO_DATE:
print 'Up to date'
return
result = 'No new version of Bazarr available.'
pass
# We can just fastforward
elif merge_result & pygit2.GIT_MERGE_ANALYSIS_FASTFORWARD:
repo.checkout_tree(repo.get(remote_id))
master_ref = repo.lookup_reference('refs/heads/master')
master_ref.set_target(remote_id)
repo.head.set_target(remote_id)
result = 'Bazarr updated to latest version.'
os.execlp('python', 'python', os.path.join(os.path.dirname(__file__), 'bazarr.py'))
else:
raise AssertionError('Unknown merge analysis result')
return result

@ -1,3 +1,4 @@
from get_general_settings import *
from get_series import *
from get_episodes import *
from get_subtitle import *
@ -6,7 +7,8 @@ from check_update import *
from apscheduler.schedulers.background import BackgroundScheduler
scheduler = BackgroundScheduler()
scheduler.add_job(check_and_apply_update, 'interval', hours=6, max_instances=1, coalesce=True, id='update_bazarr', name='Update bazarr from source on Github')
if automatic == 'True':
scheduler.add_job(check_and_apply_update, 'interval', hours=6, max_instances=1, coalesce=True, id='update_bazarr', name='Update bazarr from source on Github')
scheduler.add_job(update_series, 'interval', minutes=1, max_instances=1, coalesce=True, id='update_series', name='Update series list from Sonarr')
scheduler.add_job(add_new_episodes, 'interval', minutes=1, max_instances=1, coalesce=True, id='add_new_episodes', name='Add new episodes from Sonarr')
scheduler.add_job(wanted_search_missing_subtitles, 'interval', minutes=15, max_instances=1, coalesce=True, id='wanted_search_missing_subtitles', name='Search for wanted subtitles')

@ -236,7 +236,7 @@
<label>Manual update</label>
</div>
<div class="eleven wide column">
<button id="settings_general_check_update" class="ui blue button">Check now and update</button>
<a id="settings_general_check_update" class="ui blue button">Check now and update</a>
</div>
</div>
</div>
@ -372,7 +372,7 @@
;
$('#settings_general_check_update').click(function(){
window.location.href = '{{base_url}}check_update';
window.location = '{{base_url}}check_update';
})
$('a:not(.tabs), button:not(.cancel)').click(function(){

Loading…
Cancel
Save