mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
disable wal on win32
another attempt at fixing 'database locked' errors on windows, based on the suspicion that pysqlite is holding an open statement handle that is preventing the switch from wal mode on close also remove unused sync arg
This commit is contained in:
parent
2131c0049f
commit
a951026413
1 changed files with 4 additions and 6 deletions
|
@ -6,14 +6,14 @@ import copy
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from anki.lang import _
|
from anki.lang import _
|
||||||
from anki.utils import intTime, json
|
from anki.utils import intTime, json, isWin
|
||||||
from anki.db import DB
|
from anki.db import DB
|
||||||
from anki.collection import _Collection
|
from anki.collection import _Collection
|
||||||
from anki.consts import *
|
from anki.consts import *
|
||||||
from anki.stdmodels import addBasicModel, addClozeModel, addForwardReverse, \
|
from anki.stdmodels import addBasicModel, addClozeModel, addForwardReverse, \
|
||||||
addForwardOptionalReverse, addBasicTypingModel
|
addForwardOptionalReverse, addBasicTypingModel
|
||||||
|
|
||||||
def Collection(path, lock=True, server=False, sync=True, log=False):
|
def Collection(path, lock=True, server=False, 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)
|
||||||
|
@ -30,11 +30,9 @@ def Collection(path, lock=True, server=False, sync=True, log=False):
|
||||||
else:
|
else:
|
||||||
ver = _upgradeSchema(db)
|
ver = _upgradeSchema(db)
|
||||||
db.execute("pragma temp_store = memory")
|
db.execute("pragma temp_store = memory")
|
||||||
if sync:
|
db.execute("pragma cache_size = 10000")
|
||||||
db.execute("pragma cache_size = 10000")
|
if not isWin:
|
||||||
db.execute("pragma journal_mode = wal")
|
db.execute("pragma journal_mode = wal")
|
||||||
else:
|
|
||||||
db.execute("pragma synchronous = off")
|
|
||||||
db.setAutocommit(False)
|
db.setAutocommit(False)
|
||||||
# add db to col and do any remaining upgrades
|
# add db to col and do any remaining upgrades
|
||||||
col = _Collection(db, server, log)
|
col = _Collection(db, server, log)
|
||||||
|
|
Loading…
Reference in a new issue