Always sync a specfically queried change

If a change is opened by id and already exists locally, perform
a high-priority background sync of the change to make sure it's
up to date.  This should help avoid the problem where a user
returns to a change in an unsubscribed project and it appears out
of date.

If the change doesn't exist locally, it is synced in the foreground
so that case is already covered.

Change-Id: Idb5daa4309b712e39eb7cde56afcb94fdb41f179
This commit is contained in:
James E. Blair 2016-01-14 18:28:44 -08:00
parent 2d1113577a
commit c23b0b04f6
1 changed files with 5 additions and 1 deletions

View File

@ -450,7 +450,7 @@ class App(object):
self.popup(dialog, min_width=76, min_height=len(lines)+4)
def _syncOneChangeFromQuery(self, query):
number = changeid = None
number = changeid = restid = None
if query.startswith("change:"):
number = query.split(':')[1].strip()
try:
@ -466,6 +466,7 @@ class App(object):
elif changeid:
change = session.getChangeByChangeID(changeid)
change_key = change and change.key or None
restid = change and change.id or None
if change_key is None:
if self.sync.offline:
raise Exception('Can not sync change while offline.')
@ -491,6 +492,9 @@ class App(object):
elif changeid:
change = session.getChangeByChangeID(changeid)
change_key = change and change.key or None
elif restid:
task = sync.SyncChangeTask(restid, sync.HIGH_PRIORITY)
self.sync.submitTask(task)
if change_key is None:
raise Exception('Change is not in local database.')