diff options
-rw-r--r-- | bitbake/lib/prserv/db.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/bitbake/lib/prserv/db.py b/bitbake/lib/prserv/db.py index 79c9001bf5..88ed8e2125 100644 --- a/bitbake/lib/prserv/db.py +++ b/bitbake/lib/prserv/db.py | |||
@@ -78,6 +78,18 @@ class PRTable(object): | |||
78 | else: | 78 | else: |
79 | return False | 79 | return False |
80 | 80 | ||
81 | def test_checksum_value(self, version, pkgarch, checksum, value): | ||
82 | """Returns whether the specified value is found in the database for the specified package, architecture and checksum""" | ||
83 | |||
84 | with closing(self.conn.cursor()) as cursor: | ||
85 | data=cursor.execute("SELECT value FROM %s WHERE version=? AND pkgarch=? and checksum=? and value=?;" % self.table, | ||
86 | (version, pkgarch, checksum, value)) | ||
87 | row=data.fetchone() | ||
88 | if row is not None: | ||
89 | return True | ||
90 | else: | ||
91 | return False | ||
92 | |||
81 | def test_value(self, version, pkgarch, value): | 93 | def test_value(self, version, pkgarch, value): |
82 | """Returns whether the specified value is found in the database for the specified package and architecture""" | 94 | """Returns whether the specified value is found in the database for the specified package and architecture""" |
83 | 95 | ||
@@ -143,15 +155,13 @@ class PRTable(object): | |||
143 | return base + ".0" | 155 | return base + ".0" |
144 | 156 | ||
145 | def store_value(self, version, pkgarch, checksum, value): | 157 | def store_value(self, version, pkgarch, checksum, value): |
146 | """Store new value in the database""" | 158 | """Store value in the database""" |
147 | 159 | ||
148 | with closing(self.conn.cursor()) as cursor: | 160 | if not self.read_only and not self.test_checksum_value(version, pkgarch, checksum, value): |
149 | try: | 161 | with closing(self.conn.cursor()) as cursor: |
150 | cursor.execute("INSERT INTO %s VALUES (?, ?, ?, ?);" % (self.table), | 162 | cursor.execute("INSERT INTO %s VALUES (?, ?, ?, ?);" % (self.table), |
151 | (version, pkgarch, checksum, value)) | 163 | (version, pkgarch, checksum, value)) |
152 | except sqlite3.IntegrityError as exc: | 164 | self.conn.commit() |
153 | logger.error(str(exc)) | ||
154 | self.conn.commit() | ||
155 | 165 | ||
156 | def _get_value(self, version, pkgarch, checksum, history): | 166 | def _get_value(self, version, pkgarch, checksum, history): |
157 | 167 | ||