component_id_cache = {}
location_id_cache = {}
maintainer_id_cache = {}
+keyring_id_cache = {}
source_id_cache = {}
files_id_cache = {}
maintainer_cache = {}
fingerprint_id_cache = {}
queue_id_cache = {}
uid_id_cache = {}
+suite_version_cache = {}
################################################################################
def get_location_id (location, component, archive):
global location_id_cache
- cache_key = location + '~' + component + '~' + location
+ cache_key = location + '_' + component + '_' + location
if location_id_cache.has_key(cache_key):
return location_id_cache[cache_key]
def get_source_id (source, version):
global source_id_cache
- cache_key = source + '~' + version + '~'
+ cache_key = source + '_' + version + '_'
if source_id_cache.has_key(cache_key):
return source_id_cache[cache_key]
return source_id
+def get_suite_version(source, suite):
+ global suite_version_cache
+ cache_key = "%s_%s" % (source, suite)
+
+ if suite_version_cache.has_key(cache_key):
+ return suite_version_cache[cache_key]
+
+ q = projectB.query("""
+ SELECT s.version FROM source s, suite su, src_associations sa
+ WHERE sa.source=s.id
+ AND sa.suite=su.id
+ AND su.suite_name='%s'
+ AND s.source='%s'"""
+ % (suite, source))
+
+ if not q.getresult():
+ return None
+
+ version = q.getresult()[0][0]
+ suite_version_cache[cache_key] = version
+
+ return version
+
################################################################################
def get_or_set_maintainer_id (maintainer):
################################################################################
+def get_or_set_keyring_id (keyring):
+ global keyring_id_cache
+
+ if keyring_id_cache.has_key(keyring):
+ return keyring_id_cache[keyring]
+
+ q = projectB.query("SELECT id FROM keyrings WHERE name = '%s'" % (keyring))
+ if not q.getresult():
+ projectB.query("INSERT INTO keyrings (name) VALUES ('%s')" % (keyring))
+ q = projectB.query("SELECT id FROM keyrings WHERE name = '%s'" % (keyring))
+ keyring_id = q.getresult()[0][0]
+ keyring_id_cache[keyring] = keyring_id
+
+ return keyring_id
+
+################################################################################
+
def get_or_set_uid_id (uid):
global uid_id_cache
################################################################################
-def get_files_id (filename, size, md5sum, location_id):
+def get_files_id (filename, size, md5sum, sha1sum, sha256sum, location_id):
global files_id_cache
- cache_key = "%s~%d" % (filename, location_id)
+ cache_key = "%s_%d" % (filename, location_id)
if files_id_cache.has_key(cache_key):
return files_id_cache[cache_key]
size = int(size)
- q = projectB.query("SELECT id, size, md5sum FROM files WHERE filename = '%s' AND location = %d" % (filename, location_id))
+ q = projectB.query("SELECT id, size, md5sum, sha1sum, sha256sum FROM files WHERE filename = '%s' AND location = %d" % (filename, location_id))
ql = q.getresult()
if ql:
if len(ql) != 1:
ql = ql[0]
orig_size = int(ql[1])
orig_md5sum = ql[2]
- if orig_size != size or orig_md5sum != md5sum:
+ orig_sha1sum = ql[3]
+ orig_sha256sum = ql[4]
+ if orig_size != size or orig_md5sum != md5sum or orig_sha1sum != sha1sum or orig_sha256sum != sha256sum:
return -2
files_id_cache[cache_key] = ql[0]
return files_id_cache[cache_key]
################################################################################
-def set_files_id (filename, size, md5sum, location_id):
+def set_files_id (filename, size, md5sum, sha1sum, sha256sum, location_id):
global files_id_cache
- projectB.query("INSERT INTO files (filename, size, md5sum, location) VALUES ('%s', %d, '%s', %d)" % (filename, long(size), md5sum, location_id))
+ projectB.query("INSERT INTO files (filename, size, md5sum, sha1sum, sha256sum, location) VALUES ('%s', %d, '%s', %d)" % (filename, long(size), md5sum, sha1sum, sha256sum, location_id))
- return get_files_id (filename, size, md5sum, location_id)
+ return get_files_id (filename, size, md5sum, sha1sum, sha256sum, location_id)
### currval has issues with postgresql 7.1.3 when the table is big
### it was taking ~3 seconds to return on auric which is very Not
##
##q = projectB.query("SELECT id FROM files WHERE id = currval('files_id_seq')")
##ql = q.getresult()[0]
- ##cache_key = "%s~%d" % (filename, location_id)
+ ##cache_key = "%s_%d" % (filename, location_id)
##files_id_cache[cache_key] = ql[0]
##return files_id_cache[cache_key]