mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 09:22:31 -06:00
avoid sqlite deadlock on windows
This commit is contained in:
parent
f9c159a051
commit
c73ff3ce1b
|
@ -21,6 +21,12 @@ except:
|
||||||
HAVE_SQLITE3 = False
|
HAVE_SQLITE3 = False
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
from pathlib import Path
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class U2idx(object):
|
class U2idx(object):
|
||||||
def __init__(self, conn):
|
def __init__(self, conn):
|
||||||
self.log_func = conn.log_func
|
self.log_func = conn.log_func
|
||||||
|
@ -76,7 +82,22 @@ class U2idx(object):
|
||||||
if not bos.path.exists(db_path):
|
if not bos.path.exists(db_path):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
cur = None
|
||||||
|
if ANYWIN:
|
||||||
|
uri = ""
|
||||||
|
try:
|
||||||
|
uri = "{}?mode=ro&nolock=1".format(Path(db_path).as_uri())
|
||||||
|
cur = sqlite3.connect(uri, 2, uri=True).cursor()
|
||||||
|
self.log("ro: {}".format(db_path))
|
||||||
|
except:
|
||||||
|
self.log("could not open read-only: {}\n{}".format(uri, min_ex()))
|
||||||
|
|
||||||
|
if not cur:
|
||||||
|
# on windows, this steals the write-lock from up2k.deferred_init --
|
||||||
|
# seen on win 10.0.17763.2686, py 3.10.4, sqlite 3.37.2
|
||||||
cur = sqlite3.connect(db_path, 2).cursor()
|
cur = sqlite3.connect(db_path, 2).cursor()
|
||||||
|
self.log("opened {}".format(db_path))
|
||||||
|
|
||||||
self.cur[ptop] = cur
|
self.cur[ptop] = cur
|
||||||
return cur
|
return cur
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue