Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/db.py
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | def content_missing_per_sha1(self, sha1s, cur=None): | ||||
cur = self._cursor(cur) | cur = self._cursor(cur) | ||||
yield from execute_values_generator(cur, """ | yield from execute_values_generator(cur, """ | ||||
SELECT t.sha1 FROM (VALUES %s) AS t(sha1) | SELECT t.sha1 FROM (VALUES %s) AS t(sha1) | ||||
WHERE NOT EXISTS ( | WHERE NOT EXISTS ( | ||||
SELECT 1 FROM content c WHERE c.sha1 = t.sha1 | SELECT 1 FROM content c WHERE c.sha1 = t.sha1 | ||||
)""", ((sha1,) for sha1 in sha1s)) | )""", ((sha1,) for sha1 in sha1s)) | ||||
def skipped_content_missing_from_temp(self, cur=None): | def skipped_content_missing(self, contents, cur=None): | ||||
cur = self._cursor(cur) | if not contents: | ||||
return [] | |||||
cur.execute("""SELECT sha1, sha1_git, sha256, blake2s256 | cur = self._cursor(cur) | ||||
FROM swh_skipped_content_missing()""") | |||||
query = """SELECT * FROM (VALUES %s) AS t (%s) | |||||
WHERE not exists | |||||
(SELECT 1 FROM skipped_content s WHERE | |||||
s.sha1 is not distinct from t.sha1 and | |||||
s.sha1_git is not distinct from t.sha1_git and | |||||
s.sha256 is not distinct from t.sha256);""" % \ | |||||
((', '.join('%s' for _ in contents)), | |||||
', '.join(self.content_hash_keys)) | |||||
cur.execute(query, | |||||
[tuple(cont[key] for key in self.content_hash_keys) | |||||
for cont in contents]) | |||||
yield from cur | yield from cur | ||||
def snapshot_exists(self, snapshot_id, cur=None): | def snapshot_exists(self, snapshot_id, cur=None): | ||||
"""Check whether a snapshot with the given id exists""" | """Check whether a snapshot with the given id exists""" | ||||
cur = self._cursor(cur) | cur = self._cursor(cur) | ||||
cur.execute("""SELECT 1 FROM snapshot where id=%s""", (snapshot_id,)) | cur.execute("""SELECT 1 FROM snapshot where id=%s""", (snapshot_id,)) | ||||
▲ Show 20 Lines • Show All 755 Lines • Show Last 20 Lines |