mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
don't open log for export or upgrade, only regular+sync
This commit is contained in:
parent
9f548ad85a
commit
ef9157a8ee
4 changed files with 13 additions and 12 deletions
|
@ -51,9 +51,8 @@ defaultConf = {
|
||||||
# this is initialized by storage.Collection
|
# this is initialized by storage.Collection
|
||||||
class _Collection(object):
|
class _Collection(object):
|
||||||
|
|
||||||
debugLog = False
|
def __init__(self, db, server=False, log=False):
|
||||||
|
self._debugLog = log
|
||||||
def __init__(self, db, server=False):
|
|
||||||
self.db = db
|
self.db = db
|
||||||
self.path = db._path
|
self.path = db._path
|
||||||
self._openLog()
|
self._openLog()
|
||||||
|
@ -783,7 +782,7 @@ and queue = 0""", intTime(), self.usn())
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
def log(self, *args, **kwargs):
|
def log(self, *args, **kwargs):
|
||||||
if not self.debugLog:
|
if not self._debugLog:
|
||||||
return
|
return
|
||||||
def customRepr(x):
|
def customRepr(x):
|
||||||
if isinstance(x, basestring):
|
if isinstance(x, basestring):
|
||||||
|
@ -798,7 +797,7 @@ and queue = 0""", intTime(), self.usn())
|
||||||
print buf
|
print buf
|
||||||
|
|
||||||
def _openLog(self):
|
def _openLog(self):
|
||||||
if not self.debugLog:
|
if not self._debugLog:
|
||||||
return
|
return
|
||||||
lpath = re.sub("\.anki2$", ".log", self.path)
|
lpath = re.sub("\.anki2$", ".log", self.path)
|
||||||
self._logHnd = open(lpath, "ab")
|
self._logHnd = open(lpath, "ab")
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# 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.lang import _
|
||||||
from anki.utils import intTime, json
|
from anki.utils import intTime, json
|
||||||
from anki.db import DB
|
from anki.db import DB
|
||||||
|
@ -11,7 +14,8 @@ from anki.consts import *
|
||||||
from anki.stdmodels import addBasicModel, addClozeModel, addForwardReverse, \
|
from anki.stdmodels import addBasicModel, addClozeModel, addForwardReverse, \
|
||||||
addForwardOptionalReverse
|
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."
|
"Open a new or existing collection. Path must be unicode."
|
||||||
assert path.endswith(".anki2")
|
assert path.endswith(".anki2")
|
||||||
path = os.path.abspath(path)
|
path = os.path.abspath(path)
|
||||||
|
@ -33,7 +37,7 @@ def Collection(path, lock=True, server=False, sync=True):
|
||||||
else:
|
else:
|
||||||
db.execute("pragma synchronous = off")
|
db.execute("pragma synchronous = off")
|
||||||
# add db to col and do any remaining upgrades
|
# add db to col and do any remaining upgrades
|
||||||
col = _Collection(db, server)
|
col = _Collection(db, server, log)
|
||||||
if ver < SCHEMA_VERSION:
|
if ver < SCHEMA_VERSION:
|
||||||
_upgrade(col, ver)
|
_upgrade(col, ver)
|
||||||
elif create:
|
elif create:
|
||||||
|
|
|
@ -31,8 +31,6 @@ class AnkiQt(QMainWindow):
|
||||||
self.state = "startup"
|
self.state = "startup"
|
||||||
aqt.mw = self
|
aqt.mw = self
|
||||||
self.app = app
|
self.app = app
|
||||||
from anki.collection import _Collection
|
|
||||||
_Collection.debugLog = True
|
|
||||||
if isWin:
|
if isWin:
|
||||||
self._xpstyle = QStyleFactory.create("WindowsXP")
|
self._xpstyle = QStyleFactory.create("WindowsXP")
|
||||||
self.app.setStyle(self._xpstyle)
|
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):
|
def loadCollection(self):
|
||||||
self.hideSchemaMsg = True
|
self.hideSchemaMsg = True
|
||||||
try:
|
try:
|
||||||
self.col = Collection(self.pm.collectionPath())
|
self.col = Collection(self.pm.collectionPath(), log=True)
|
||||||
except anki.db.Error:
|
except anki.db.Error:
|
||||||
# move back to profile manager
|
# move back to profile manager
|
||||||
showWarning("""\
|
showWarning("""\
|
||||||
|
|
|
@ -280,7 +280,7 @@ class SyncThread(QThread):
|
||||||
self.syncMsg = ""
|
self.syncMsg = ""
|
||||||
self.uname = ""
|
self.uname = ""
|
||||||
try:
|
try:
|
||||||
self.col = Collection(self.path)
|
self.col = Collection(self.path, log=True)
|
||||||
except:
|
except:
|
||||||
self.fireEvent("corrupt")
|
self.fireEvent("corrupt")
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue