From 1d2ef1dbfb0d5113bc0a6726888978b04af3e864 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 3 Nov 2013 18:39:03 +0900 Subject: [PATCH] seeking on win32 is slow, so keep file handle around --- aqt/main.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/aqt/main.py b/aqt/main.py index 46ff38327..00d5617e0 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -268,6 +268,7 @@ To import into a password protected profile, please open the profile before atte def loadCollection(self): self.hideSchemaMsg = True + self._openLog() try: self.col = Collection(self.pm.collectionPath()) except anki.db.Error: @@ -315,6 +316,7 @@ when the collection is stored on a network or cloud drive. Please see \ the manual for information on how to restore from an automatic backup.")) self.col.close() self.col = None + self._closeLog() if not corrupt: self.backup() self.progress.finish() @@ -894,11 +896,18 @@ Difference to correct time: %s.""") % diffText limit=4+kwargs.get("stack", 0))[0] buf = u"[%s] %s:%s(): %s" % (intTime(), os.path.basename(path), fn, ", ".join([customRepr(x) for x in args])) - lpath = re.sub("\.anki2$", ".log", self.pm.collectionPath()) - open(lpath, "ab").write(buf.encode("utf8") + "\n") + self._logHnd.write(buf.encode("utf8") + "\n") + self._logHnd.flush() if os.environ.get("ANKIDEV"): print buf + def _openLog(self): + lpath = re.sub("\.anki2$", ".log", self.pm.collectionPath()) + self._logHnd = open(lpath, "ab") + + def _closeLog(self): + self._logHnd = None + # Schema modifications ##########################################################################