mirror of
https://github.com/lilydjwg/archrepo2.git
synced 2025-03-10 12:02:43 +00:00
check database version before use
This commit is contained in:
parent
9ac3ed8f3b
commit
b3d9560c2d
3 changed files with 7 additions and 1 deletions
|
@ -21,6 +21,7 @@ import tornado.process
|
||||||
|
|
||||||
import archpkg
|
import archpkg
|
||||||
import pkgreader
|
import pkgreader
|
||||||
|
import dbutil
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -190,7 +191,12 @@ class EventHandler(pyinotify.ProcessEvent):
|
||||||
|
|
||||||
base = config.get('path')
|
base = config.get('path')
|
||||||
dbname = config.get('info-db', os.path.join(base, 'pkginfo.db'))
|
dbname = config.get('info-db', os.path.join(base, 'pkginfo.db'))
|
||||||
|
new_db = not os.path.exists(dbname)
|
||||||
self._db = sqlite3.connect(dbname, isolation_level=None) # isolation_level=None means autocommit
|
self._db = sqlite3.connect(dbname, isolation_level=None) # isolation_level=None means autocommit
|
||||||
|
if new_db:
|
||||||
|
dbutil.setver(self._db, '0.2')
|
||||||
|
else:
|
||||||
|
assert dbutil.getver(self._db) == '0.2', 'wrong database version, please upgrade (see scripts directory)'
|
||||||
self._db.execute('''create table if not exists pkginfo
|
self._db.execute('''create table if not exists pkginfo
|
||||||
(filename text unique,
|
(filename text unique,
|
||||||
pkgname text,
|
pkgname text,
|
||||||
|
|
|
@ -10,7 +10,7 @@ top_dir = os.path.normpath(os.path.join(__file__, '../..'))
|
||||||
sys.path.append(top_dir)
|
sys.path.append(top_dir)
|
||||||
|
|
||||||
import pkgreader
|
import pkgreader
|
||||||
from common import *
|
from dbutil import *
|
||||||
|
|
||||||
def main(conffile):
|
def main(conffile):
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
|
|
Loading…
Add table
Reference in a new issue