fix full upload

This commit is contained in:
Damien Elmes 2011-12-04 15:30:12 +09:00
parent e03b51fae8
commit 67285cd230
2 changed files with 10 additions and 11 deletions

View file

@ -820,6 +820,9 @@ Please choose a new deck name:"""))
addHook("modSchema", self.onSchemaMod) addHook("modSchema", self.onSchemaMod)
def onSchemaMod(self, arg): def onSchemaMod(self, arg):
# if triggered in sync, make sure we don't use the gui
if not self.inMainThread():
return True
return askUser(_("""\ return askUser(_("""\
This operation can't be merged when syncing, so if you have made \ This operation can't be merged when syncing, so if you have made \
changes on other devices that haven't been synced to this device yet, \ changes on other devices that haven't been synced to this device yet, \

View file

@ -42,26 +42,22 @@ class SyncManager(QObject):
t = self.thread = SyncThread( t = self.thread = SyncThread(
self.pm.collectionPath(), self.pm.profile['syncKey'], self.pm.collectionPath(), self.pm.profile['syncKey'],
auth=auth, media=self.pm.profile['syncMedia']) auth=auth, media=self.pm.profile['syncMedia'])
print "created thread"
self.connect(t, SIGNAL("event"), self.onEvent) self.connect(t, SIGNAL("event"), self.onEvent)
self.mw.progress.start(immediate=True, label=_("Connecting...")) self.mw.progress.start(immediate=True, label=_("Syncing..."))
print "starting thread"
self.thread.start() self.thread.start()
while not self.thread.isFinished(): while not self.thread.isFinished():
self.mw.app.processEvents() self.mw.app.processEvents()
self.thread.wait(100) self.thread.wait(100)
print "finished"
self.mw.progress.finish() self.mw.progress.finish()
def onEvent(self, evt, *args): def onEvent(self, evt, *args):
if evt == "badAuth": if evt == "badAuth":
return tooltip( tooltip(
_("AnkiWeb ID or password was incorrect; please try again."), _("AnkiWeb ID or password was incorrect; please try again."),
parent=self.mw) parent=self.mw)
elif evt == "newKey": elif evt == "newKey":
self.pm.profile['syncKey'] = args[0] self.pm.profile['syncKey'] = args[0]
self.pm.save() self.pm.save()
print "saved hkey"
elif evt == "sync": elif evt == "sync":
self.mw.progress.update(label="sync: "+args[0]) self.mw.progress.update(label="sync: "+args[0])
elif evt == "mediaSync": elif evt == "mediaSync":
@ -72,7 +68,7 @@ class SyncManager(QObject):
elif evt == "clockOff": elif evt == "clockOff":
print "clock is wrong" print "clock is wrong"
elif evt == "noChanges": elif evt == "noChanges":
print "no changes found" pass
elif evt == "fullSync": elif evt == "fullSync":
self._confirmFullSync() self._confirmFullSync()
elif evt == "success": elif evt == "success":
@ -192,9 +188,10 @@ class SyncThread(QThread):
# run sync and catch any errors # run sync and catch any errors
try: try:
self._sync() self._sync()
except Exception, e: except:
print e err = traceback.format_exc()
self.fireEvent("error", unicode(e)) print err
self.fireEvent("error", err)
finally: finally:
# don't bump mod time unless we explicitly save # don't bump mod time unless we explicitly save
self.col.close(save=False) self.col.close(save=False)
@ -203,7 +200,6 @@ class SyncThread(QThread):
if self.auth: if self.auth:
# need to authenticate and obtain host key # need to authenticate and obtain host key
hkey = self.server.hostKey(*self.auth) hkey = self.server.hostKey(*self.auth)
print "hkey was", hkey
if not hkey: if not hkey:
# provided details were invalid # provided details were invalid
return self.fireEvent("badAuth") return self.fireEvent("badAuth")