[yum-git] yum/yumRepo.py
James Antill
james at linux.duke.edu
Thu Jan 24 23:40:12 UTC 2008
yum/yumRepo.py | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
New commits:
commit 80dcf85412d2e0cb2dc10035623a075c9c708123
Author: James Antill <james at and.org>
Date: Thu Jan 24 18:40:08 2008 -0500
Fix the downloading compressed MD files problem.
Save DL'ing filenames so they can be unlinked() on revert.
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 20551bb..c8ea463 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -777,7 +777,7 @@ class YumRepository(Repository, config.RepoConf):
shutil.copy2(local, old_local)
xml = self._parseRepoXML(old_local, True)
self._oldRepoMDData = {'old_repo_XML' : xml, 'local' : local,
- 'old_local' : old_local}
+ 'old_local' : old_local, 'new_MD_files' : []}
return True
return False
@@ -787,6 +787,10 @@ class YumRepository(Repository, config.RepoConf):
if not len(self._oldRepoMDData):
return
+ # Unique names mean the rename doesn't work anymore.
+ for fname in self._oldRepoMDData['new_MD_files']:
+ os.unlink(fname)
+
old_data = self._oldRepoMDData
self._oldRepoMDData = {}
@@ -894,15 +898,20 @@ class YumRepository(Repository, config.RepoConf):
return True
return False
- def _groupCheckDataMDValid(self, data, dbmdtype, mmdtype):
+ def _groupCheckDataMDValid(self, data, dbmdtype, mmdtype, file_check=False):
""" Check that we already have this data, and that it's valid. Given
the DB mdtype and the main mdtype (no _db suffix). """
if data is None:
return None
-
- compressed = (dbmdtype != mmdtype)
- local = self._get_mdtype_fname(data, compressed)
+
+ if not file_check:
+ compressed = (dbmdtype != mmdtype)
+ local = self._get_mdtype_fname(data, compressed)
+ else:
+ local = self._get_mdtype_fname(data, False)
+ if not os.path.exists(local):
+ local = local.replace('.bz2', '')
if not self._checkMD(local, dbmdtype, openchecksum=compressed,
data=data, check_can_fail=True):
return None
@@ -938,7 +947,7 @@ class YumRepository(Repository, config.RepoConf):
if old_repo_XML:
(omdtype, odata) = self._get_mdtype_data(mdtype,
repoXML=old_repo_XML)
- local = self._groupCheckDataMDValid(odata, omdtype, mdtype)
+ local = self._groupCheckDataMDValid(odata, omdtype,mdtype,False)
if local:
if _mdtype_eq(omdtype, odata, nmdtype, ndata):
continue # If they are the same do nothing
@@ -963,6 +972,14 @@ class YumRepository(Repository, config.RepoConf):
self._revertOldRepoXML()
return False
+ local = self._get_mdtype_fname(ndata, False)
+ if nmdtype != mdtype: # Uncompress any .sqlite.bz2 files
+ dl_local = local
+ local = local.replace('.bz2', '')
+ misc.bunzipFile(dl_local, local)
+ os.unlink(dl_local)
+ self._oldRepoMDData['new_MD_files'].append(local)
+
self._doneOldRepoXML()
return True
More information about the Yum-cvs-commits
mailing list