[yum-cvs] yum/yum constants.py, 1.9, 1.10 repoMDObject.py, 1.5, 1.6 sqlitecache.py, 1.16, 1.17 yumRepo.py, 1.34, 1.35
Seth Vidal
skvidal at linux.duke.edu
Wed Feb 7 06:48:38 UTC 2007
Update of /home/groups/yum/cvs/yum/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv12325/yum
Modified Files:
constants.py repoMDObject.py sqlitecache.py yumRepo.py
Log Message:
check dbversion before downloading sqlite dbs
move dbversion into constants
Index: constants.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/constants.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- constants.py 19 Aug 2006 20:03:35 -0000 1.9
+++ constants.py 7 Feb 2007 06:48:36 -0000 1.10
@@ -71,6 +71,9 @@
PLUG_OPT_WHERE_REPO = 1
PLUG_OPT_WHERE_ALL = 2
+# version of sqlite database schemas
+DBVERSION = '9'
+
# boolean dict:
BOOLEAN_STATES = {'1': True, 'yes': True, 'true': True, 'on': True,
'0': False, 'no': False, 'false': False, 'off': False}
Index: repoMDObject.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/repoMDObject.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- repoMDObject.py 3 Feb 2007 22:04:11 -0000 1.5
+++ repoMDObject.py 7 Feb 2007 06:48:36 -0000 1.6
@@ -35,6 +35,7 @@
self.checksum = (None,None) # type,value
self.openchecksum = (None,None) # type,value
self.timestamp = None
+ self.dbversion = None
self.parse(elem)
@@ -59,7 +60,8 @@
elif child_name == 'timestamp':
self.timestamp = child.text
-
+ elif child_name == 'database_version':
+ self.dbversion = child.text
class RepoMD:
"""represents the repomd xml file"""
@@ -109,6 +111,7 @@
print 'timestamp: %s' % thisdata.timestamp
print 'checksum: %s -%s' % thisdata.checksum
print 'open checksum: %s - %s' % thisdata.openchecksum
+ print 'dbversion: %s' % thisdata.dbversion
def main():
Index: sqlitecache.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/sqlitecache.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- sqlitecache.py 3 Feb 2007 21:47:43 -0000 1.16
+++ sqlitecache.py 7 Feb 2007 06:48:36 -0000 1.17
@@ -28,11 +28,8 @@
import logging
import logginglevels
from sqlitesack import encodefiletypelist,encodefilenamelist
+from constants import *
-# This version refers to the internal structure of the sqlite cache files
-# increasing this number forces all caches of a lower version number
-# to be re-generated
-dbversion = '9'
from sqlutils import executeSQL
@@ -68,8 +65,8 @@
raise sqlite.DatabaseError, "Incomplete database cache file"
# Now check the database version
- if (info['dbversion'] != dbversion):
- self.verbose_logger.log(logginglevels.INFO_2, "Warning: cache file is version %s, we need %s, will regenerate", info['dbversion'], dbversion)
+ if (info['dbversion'] != DBVERSION):
+ self.verbose_logger.log(logginglevels.INFO_2, "Warning: cache file is version %s, we need %s, will regenerate", info['dbversion'], DBVERSION)
raise sqlite.DatabaseError, "Older version of yum sqlite"
# This appears to be a valid database, return checksum value and
@@ -401,7 +398,7 @@
executeSQL(cur, "DELETE FROM "+table+ " where pkgKey in %s" %(delpkgs,))
executeSQL(cur, "INSERT into db_info (dbversion,checksum) VALUES (?,?)",
- (dbversion,checksum))
+ (DBVERSION,checksum))
db.commit()
self.verbose_logger.log(logginglevels.INFO_2, "Added %s new packages, deleted %s old in %.2f seconds",
newcount, delcount, time.time()-t)
Index: yumRepo.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/yumRepo.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- yumRepo.py 4 Feb 2007 18:25:44 -0000 1.34
+++ yumRepo.py 7 Feb 2007 06:48:36 -0000 1.35
@@ -30,6 +30,7 @@
import storagefactory
from yum import config
from yum import misc
+from constants import *
import logging
import logginglevels
@@ -106,12 +107,15 @@
continue
db_fn = None
+
if item == 'metadata':
- # retrieve _db first, if it exists, and bunzip2 it
- try:
- db_fn = repo.retrieveMD('primary_db')
- except Errors.RepoMDError, e:
- pass
+
+ if self._check_db_version(repo, 'primary_db'):
+ # retrieve _db first, if it exists, and bunzip2 it
+ try:
+ db_fn = repo.retrieveMD('primary_db')
+ except Errors.RepoMDError, e:
+ pass
if db_fn:
db_un_fn = db_fn.replace('.bz2', '')
@@ -130,13 +134,14 @@
del dobj
elif item == 'filelists':
- try:
- db_fn = repo.retrieveMD('filelists_db')
- except Errors.RepoMDError, e:
- pass
+ if self._check_db_version(repo, 'filelists_db'):
+ try:
+ db_fn = repo.retrieveMD('filelists_db')
+ except Errors.RepoMDError, e:
+ pass
if db_fn:
- db_un_fn = db_fn.replace('.bz2', '')
+ db_un_fn = db_fn.replace('.bz2', '')
if not repo.cache:
misc.bunzipFile(db_fn, db_un_fn)
dobj = repo.cacheHandler.open_database(db_un_fn)
@@ -153,10 +158,11 @@
elif item == 'otherdata':
- try:
- db_fn = repo.retrieveMD('other_db')
- except Errors.RepoMDError, e:
- pass
+ if self._check_db_version(repo, 'other_db'):
+ try:
+ db_fn = repo.retrieveMD('other_db')
+ except Errors.RepoMDError, e:
+ pass
if db_fn:
db_un_fn = db_fn.replace('.bz2', '')
@@ -180,6 +186,12 @@
# get rid of all this stuff we don't need now
del repo.cacheHandler
+ def _check_db_version(self, repo, mdtype):
+ if repo.repoXML.repoData.has_key(mdtype):
+ if DBVERSION == repo.repoXML.repoData[mdtype].dbversion:
+ return True
+ return False
+
class YumRepository(Repository, config.RepoConf):
"""
This is an actual repository object
More information about the Yum-cvs-commits
mailing list