diff options
Diffstat (limited to 'dbgenerator/database.py')
-rw-r--r-- | dbgenerator/database.py | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/dbgenerator/database.py b/dbgenerator/database.py index 57f5533..08e6cd1 100644 --- a/dbgenerator/database.py +++ b/dbgenerator/database.py @@ -29,7 +29,7 @@ class SQLPackageDatabase(object): arches = frozenset(ConstData.arches['all']) # If you change the database structure below, you should # increment this number - schema_version = 71 + schema_version = 72 # These are used to cache the various relations and # avoid more SELECT queries just to find the relations. @@ -76,8 +76,11 @@ class SQLPackageDatabase(object): changelog TEXT, changelog_mtime INT, changelog_sha1 CHAR(40), + manifest_mtime INT, + manifest_sha1 CHAR(40), PRIMARY KEY (cp), - INDEX (changelog_mtime) + INDEX (changelog_mtime), + INDEX (manifest_mtime) )""" sql['CREATE_versions'] = """ CREATE TABLE versions ( @@ -222,13 +225,18 @@ class SQLPackageDatabase(object): sql['INSERT_metadata'] = """ INSERT INTO metadata (cp, homepage, description, license, - changelog, changelog_mtime, changelog_sha1) + changelog, changelog_mtime, changelog_sha1, + manifest_mtime, manifest_sha1 + ) VALUES - (?, ?, ?, ?, ?, ?, ?) + (?, ?, ?, ?, ?, ?, ?, ?, ?) """ def add_metadata(self, category, pn, description, homepage, pkglicense, - changelog, changelog_mtime, changelog_sha1): + changelog, + changelog_mtime, changelog_sha1, + manifest_mtime, manifest_sha1 + ): """Replace the metadata for the CP with new metadata""" cp = self.find_cp(category, pn) if cp is None: @@ -238,7 +246,8 @@ class SQLPackageDatabase(object): self.del_metadata(cp) sql = self.sql['INSERT_metadata'] params = (cp, homepage, description, str(pkglicense), - changelog, changelog_mtime, changelog_sha1) + changelog, changelog_mtime, changelog_sha1, + manifest_mtime, manifest_sha1) self.cursor.execute(sql, params) self.db.commit() @@ -258,6 +267,23 @@ class SQLPackageDatabase(object): if row: result = (unicode(row[0]), int(row[1]), str(row[2])) return result + + sql['SELECT_get_manifest'] = """ + SELECT manifest_mtime, manifest_sha1 + FROM metadata + WHERE cp = ? + """ + def get_manifest(self, cat, pn): + cp = self.find_cp(cat, pn) + result = (-1, None) + if cp is None: + return result + sql = self.sql['SELECT_get_manifest'] + self.cursor.execute(sql, (cp, )) + row = self.cursor.fetchone() + if row: + result = (int(row[1]), str(row[2])) + return result sql['INSERT_versions'] = """ INSERT INTO versions |