SF.net SVN: gar:[23672] csw/mgar/gar/v2/lib
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Tue May 20 08:33:10 CEST 2014
Revision: 23672
http://sourceforge.net/p/gar/code/23672
Author: wahwah
Date: 2014-05-20 06:33:10 +0000 (Tue, 20 May 2014)
Log Message:
-----------
pkgdb: Lazy registration lev 1
Don't make the PUT request if not necessary.
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/checkpkg2.py
csw/mgar/gar/v2/lib/python/rest.py
csw/mgar/gar/v2/lib/web/releases_web.py
Modified: csw/mgar/gar/v2/lib/python/checkpkg2.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg2.py 2014-05-20 06:33:01 UTC (rev 23671)
+++ csw/mgar/gar/v2/lib/python/checkpkg2.py 2014-05-20 06:33:10 UTC (rev 23672)
@@ -173,7 +173,8 @@
entries = [MakeEntry(x) for x in file_list]
md5_sums_from_files = collector.CollectStatsFromCatalogEntries(entries, False)
for md5_sum in md5_sums_from_files:
- rest_client.RegisterLevelOne(md5_sum)
+ if not rest_client.IsRegisteredLevelOne(md5_sum):
+ rest_client.RegisterLevelOne(md5_sum)
# We need the md5 sums of these files
md5_sums.extend(md5_sums_from_files)
assert md5_sums, "The list of md5 sums must not be empty."
Modified: csw/mgar/gar/v2/lib/python/rest.py
===================================================================
--- csw/mgar/gar/v2/lib/python/rest.py 2014-05-20 06:33:01 UTC (rev 23671)
+++ csw/mgar/gar/v2/lib/python/rest.py 2014-05-20 06:33:10 UTC (rev 23672)
@@ -359,6 +359,19 @@
url = self.releases_url + "/svr4/%s/db-level-1/" % md5_sum
return self._CurlPut(url, [])
+ def IsRegisteredLevelOne(self, md5_sum):
+ self.ValidateMd5(md5_sum)
+ url = self.releases_url + "/svr4/%s/db-level-1/" % md5_sum
+ http_code = self._HttpHeadRequest(url)
+ if http_code == 404:
+ return False
+ elif http_code == 200:
+ return True
+ else:
+ raise RestCommunicationError("URL %r HTTP code: %d"
+ % (url, http_code))
+
+
@retry_decorator.Retry(tries=DEFAULT_TRIES, delay=DEFAULT_RETRY_DELAY,
exceptions=(RestCommunicationError, pycurl.error))
def IsRegisteredLevelTwo(self, md5_sum):
Modified: csw/mgar/gar/v2/lib/web/releases_web.py
===================================================================
--- csw/mgar/gar/v2/lib/web/releases_web.py 2014-05-20 06:33:01 UTC (rev 23671)
+++ csw/mgar/gar/v2/lib/web/releases_web.py 2014-05-20 06:33:10 UTC (rev 23672)
@@ -518,6 +518,15 @@
class Srv4RelationalLevelOne(object):
"""Registers the package: creates a set of relational database entries."""
+ def HEAD(self, md5_sum):
+ try:
+ srv4 = models.Srv4FileStats.selectBy(md5_sum=md5_sum).getOne()
+ except sqlobject.main.SQLObjectNotFound:
+ raise web.notfound('Stats not in the database')
+ if not srv4.registered_level_one:
+ raise web.notfound('Stats in the db, but not registered (level 1)')
+ return ''
+
def PUT(self, md5_sum):
try:
relational_util.StatsStructToDatabaseLevelOne(md5_sum)
@@ -552,7 +561,7 @@
except sqlobject.main.SQLObjectNotFound:
raise web.notfound('Stats not in the database')
if not srv4.registered_level_two:
- raise web.notfound('Stats in the db, but not registered')
+ raise web.notfound('Stats in the db, but not registered (level 2)')
return ''
# web.webapi.internalerror = web.debugerror
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list