[archive] fix NameError when SQLite database path doesn't exist
fixes regression introduced in 841bc9f6
This commit is contained in:
@@ -47,15 +47,13 @@ class DownloadArchive():
|
|||||||
_sqlite3 = None
|
_sqlite3 = None
|
||||||
|
|
||||||
def __init__(self, path, keygen, table=None, pragma=None, cache_key=None):
|
def __init__(self, path, keygen, table=None, pragma=None, cache_key=None):
|
||||||
|
|
||||||
if self._sqlite3 is None:
|
if self._sqlite3 is None:
|
||||||
import sqlite3
|
DownloadArchive._sqlite3 = __import__("sqlite3")
|
||||||
DownloadArchive._sqlite3 = sqlite3
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
con = self._sqlite3.connect(
|
con = self._sqlite3.connect(
|
||||||
path, timeout=60, check_same_thread=False)
|
path, timeout=60, check_same_thread=False)
|
||||||
except sqlite3.OperationalError:
|
except self._sqlite3.OperationalError:
|
||||||
os.makedirs(os.path.dirname(path))
|
os.makedirs(os.path.dirname(path))
|
||||||
con = self._sqlite3.connect(
|
con = self._sqlite3.connect(
|
||||||
path, timeout=60, check_same_thread=False)
|
path, timeout=60, check_same_thread=False)
|
||||||
@@ -147,8 +145,7 @@ class DownloadArchivePostgresql():
|
|||||||
|
|
||||||
def __init__(self, uri, keygen, table=None, pragma=None, cache_key=None):
|
def __init__(self, uri, keygen, table=None, pragma=None, cache_key=None):
|
||||||
if self._psycopg is None:
|
if self._psycopg is None:
|
||||||
import psycopg
|
DownloadArchivePostgresql._psycopg = __import__("psycopg")
|
||||||
DownloadArchivePostgresql._psycopg = psycopg
|
|
||||||
|
|
||||||
self.connection = con = self._psycopg.connect(uri)
|
self.connection = con = self._psycopg.connect(uri)
|
||||||
self.cursor = cursor = con.cursor()
|
self.cursor = cursor = con.cursor()
|
||||||
|
|||||||
Reference in New Issue
Block a user