[entropy.db] change schema of packagedownloads table, add size column

This commit is contained in:
Fabio Erculiani
2011-08-08 21:05:39 +02:00
parent 3ae8e6ae93
commit 14fa75edbb
3 changed files with 17 additions and 10 deletions
+12 -7
View File
@@ -441,6 +441,7 @@ class EntropyRepository(EntropyRepositoryBase):
idpackage INTEGER,
download VARCHAR,
type VARCHAR,
size INTEGER,
md5 VARCHAR,
sha1 VARCHAR,
sha256 VARCHAR,
@@ -1776,15 +1777,15 @@ class EntropyRepository(EntropyRepositoryBase):
@param package_id: package indentifier
@type package_id: int
@param package_downloads_data: list of dict composed by
(download, type, md5, sha1, sha256, sha512, gpg) as keys
(download, type, size, md5, sha1, sha256, sha512, gpg) as keys
@type package_downloads_data: list
"""
def _do_insert():
self._cursor().executemany("""
INSERT INTO packagedownloads VALUES (?,?,?,?,?,?,?,?)
""", [(package_id, edw['download'], edw['type'], edw['md5'], \
edw['sha1'], edw['sha256'], edw['sha512'], edw['gpg']) \
for edw in package_downloads_data])
INSERT INTO packagedownloads VALUES (?,?,?,?,?,?,?,?,?)
""", [(package_id, edw['download'], edw['type'], edw['size'],
edw['md5'], edw['sha1'], edw['sha256'], edw['sha512'],
edw['gpg']) for edw in package_downloads_data])
try:
# be optimistic and delay if condition
@@ -2765,7 +2766,7 @@ class EntropyRepository(EntropyRepositoryBase):
try:
cur = self._cursor().execute("""
SELECT download, type, md5, sha1, sha256, sha512, gpg
SELECT download, type, size, md5, sha1, sha256, sha512, gpg
FROM packagedownloads WHERE idpackage = (?)
""" + down_type_str, params)
except OperationalError:
@@ -2774,10 +2775,12 @@ class EntropyRepository(EntropyRepositoryBase):
return tuple()
result = []
for download, d_type, md5, sha1, sha256, sha512, gpg in cur.fetchall():
for download, d_type, size, md5, sha1, sha256, sha512, gpg in \
cur.fetchall():
result.append({
"download": download,
"type": d_type,
"size": size,
"md5": md5,
"sha1": sha1,
"sha256": sha256,
@@ -4881,6 +4884,7 @@ class EntropyRepository(EntropyRepositoryBase):
self._createProvidedLibs()
# added on Aug. 2011
self._cursor().execute("DROP TABLE packagedownloads")
if not self._doesTableExist("packagedownloads"):
self._createPackageDownloadsTable()
@@ -6077,6 +6081,7 @@ class EntropyRepository(EntropyRepositoryBase):
idpackage INTEGER,
download VARCHAR,
type VARCHAR,
size INTEGER,
md5 VARCHAR,
sha1 VARCHAR,
sha256 VARCHAR,
+3 -3
View File
@@ -2264,9 +2264,9 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore):
@keyword down_type: retrieve data for a given entry type.
Currently supported entry types are: "debug", "data".
@type down_type: string
@return: list (tuple) of dict containing "download", "type", "md5",
"sha1","sha256", "sha512", "gpg" keys. "download" contains the
relative URL (like the one returned by retrieveDownloadURL())
@return: list (tuple) of dict containing "download", "type", "size",
"md5", "sha1","sha256", "sha512", "gpg" keys. "download" contains
the relative URL (like the one returned by retrieveDownloadURL())
@rtype: tuple
@raise AttributeError: if provided down_type value is invalid
"""
@@ -4563,6 +4563,7 @@ class Server(Client):
extra_url = entropy.tools.create_package_dirpath(mydata['branch'],
nonfree = False, restricted = False) + "/" + \
os.path.basename(path)
size = entropy.tools.get_file_size(path)
md5 = entropy.tools.md5sum(path)
sha1 = entropy.tools.sha1(path)
sha256 = entropy.tools.sha256(path)
@@ -4573,6 +4574,7 @@ class Server(Client):
edw = {
'download': extra_url,
'type': down_type,
'size': size,
'md5': md5,
'sha1': sha1,
'sha256': sha256,