don't open log for export or upgrade, only regular+sync

This commit is contained in:
Damien Elmes 2013-11-13 16:48:22 +09:00
parent 9f548ad85a
commit ef9157a8ee
4 changed files with 13 additions and 12 deletions

View file

@ -51,9 +51,8 @@ defaultConf = {
# this is initialized by storage.Collection
class _Collection(object):
debugLog = False
def __init__(self, db, server=False):
def __init__(self, db, server=False, log=False):
self._debugLog = log
self.db = db
self.path = db._path
self._openLog()
@ -783,7 +782,7 @@ and queue = 0""", intTime(), self.usn())
##########################################################################
def log(self, *args, **kwargs):
if not self.debugLog:
if not self._debugLog:
return
def customRepr(x):
if isinstance(x, basestring):
@ -798,7 +797,7 @@ and queue = 0""", intTime(), self.usn())
print buf
def _openLog(self):
if not self.debugLog:
if not self._debugLog:
return
lpath = re.sub("\.anki2$", ".log", self.path)
self._logHnd = open(lpath, "ab")

View file

@ -2,7 +2,10 @@
# Copyright: Damien Elmes <anki@ichi2.net>
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os, copy, re
import os
import copy
import re
from anki.lang import _
from anki.utils import intTime, json
from anki.db import DB
@ -11,7 +14,8 @@ from anki.consts import *
from anki.stdmodels import addBasicModel, addClozeModel, addForwardReverse, \
addForwardOptionalReverse
def Collection(path, lock=True, server=False, sync=True):
def Collection(path, lock=True, server=False, sync=True, log=False):
"Open a new or existing collection. Path must be unicode."
assert path.endswith(".anki2")
path = os.path.abspath(path)
@ -33,7 +37,7 @@ def Collection(path, lock=True, server=False, sync=True):
else:
db.execute("pragma synchronous = off")
# add db to col and do any remaining upgrades
col = _Collection(db, server)
col = _Collection(db, server, log)
if ver < SCHEMA_VERSION:
_upgrade(col, ver)
elif create:

View file

@ -31,8 +31,6 @@ class AnkiQt(QMainWindow):
self.state = "startup"
aqt.mw = self
self.app = app
from anki.collection import _Collection
_Collection.debugLog = True
if isWin:
self._xpstyle = QStyleFactory.create("WindowsXP")
self.app.setStyle(self._xpstyle)
@ -270,7 +268,7 @@ To import into a password protected profile, please open the profile before atte
def loadCollection(self):
self.hideSchemaMsg = True
try:
self.col = Collection(self.pm.collectionPath())
self.col = Collection(self.pm.collectionPath(), log=True)
except anki.db.Error:
# move back to profile manager
showWarning("""\

View file

@ -280,7 +280,7 @@ class SyncThread(QThread):
self.syncMsg = ""
self.uname = ""
try:
self.col = Collection(self.path)
self.col = Collection(self.path, log=True)
except:
self.fireEvent("corrupt")
return