mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
seeking on win32 is slow, so keep file handle around
This commit is contained in:
parent
433f2b06f9
commit
1d2ef1dbfb
1 changed files with 11 additions and 2 deletions
13
aqt/main.py
13
aqt/main.py
|
@ -268,6 +268,7 @@ To import into a password protected profile, please open the profile before atte
|
||||||
|
|
||||||
def loadCollection(self):
|
def loadCollection(self):
|
||||||
self.hideSchemaMsg = True
|
self.hideSchemaMsg = True
|
||||||
|
self._openLog()
|
||||||
try:
|
try:
|
||||||
self.col = Collection(self.pm.collectionPath())
|
self.col = Collection(self.pm.collectionPath())
|
||||||
except anki.db.Error:
|
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."))
|
the manual for information on how to restore from an automatic backup."))
|
||||||
self.col.close()
|
self.col.close()
|
||||||
self.col = None
|
self.col = None
|
||||||
|
self._closeLog()
|
||||||
if not corrupt:
|
if not corrupt:
|
||||||
self.backup()
|
self.backup()
|
||||||
self.progress.finish()
|
self.progress.finish()
|
||||||
|
@ -894,11 +896,18 @@ Difference to correct time: %s.""") % diffText
|
||||||
limit=4+kwargs.get("stack", 0))[0]
|
limit=4+kwargs.get("stack", 0))[0]
|
||||||
buf = u"[%s] %s:%s(): %s" % (intTime(), os.path.basename(path), fn,
|
buf = u"[%s] %s:%s(): %s" % (intTime(), os.path.basename(path), fn,
|
||||||
", ".join([customRepr(x) for x in args]))
|
", ".join([customRepr(x) for x in args]))
|
||||||
lpath = re.sub("\.anki2$", ".log", self.pm.collectionPath())
|
self._logHnd.write(buf.encode("utf8") + "\n")
|
||||||
open(lpath, "ab").write(buf.encode("utf8") + "\n")
|
self._logHnd.flush()
|
||||||
if os.environ.get("ANKIDEV"):
|
if os.environ.get("ANKIDEV"):
|
||||||
print buf
|
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
|
# Schema modifications
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue