[Yum-devel] [PATCH 2/2] - move historyend call to before history.end() - fix a couple of typos - check to make sure we're not saving _nothing_

Seth Vidal skvidal at fedoraproject.org
Tue Jun 22 20:42:11 UTC 2010


---
 yum/__init__.py |    4 +++-
 yum/history.py  |   12 +++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/yum/__init__.py b/yum/__init__.py
index 5665617..9a0bc15 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1351,8 +1351,9 @@ class YumBase(depsolve.Depsolve):
         else:
             if self.conf.history_record and not self.ts.isTsFlagSet(rpm.RPMTRANS_FLAG_TEST):
                 herrors = [to_unicode(to_str(x)) for x in errors]
+                self.plugins.run('historyend')                
                 self.history.end(rpmdbv, 2, errors=herrors)
-                self.plugins.run('historyend')
+
                 
             self.logger.critical(_("Transaction couldn't start:"))
             for e in errors:
@@ -1473,6 +1474,7 @@ class YumBase(depsolve.Depsolve):
             ret = -1
             if resultobject is not None:
                 ret = resultobject.return_code
+            self.plugins.run('historyend')
             self.history.end(self.rpmdb.simpleVersion(main_only=True)[0], ret)
         self.rpmdb.dropCachedData()
 
diff --git a/yum/history.py b/yum/history.py
index f785b1a..f84ca61 100644
--- a/yum/history.py
+++ b/yum/history.py
@@ -580,14 +580,21 @@ class YumHistory:
 
     def write_addon_data(dataname, data):
         """append data to an arbitrary-named file in the history 
-           addon_path/transaction id location"""
+           addon_path/transaction id location,
+           returns True if write succeeded, False if not"""
         
         if not hasattr(self, '_tid'):
             # maybe we should raise an exception or a warning here?
             return False
         
+        if not dataname:
+            return False
+        
+        if not data:
+            return False
+            
         # make sure the tid dir exists
-        tid_dir = self.conf.addon_path + '/' + self._tid)
+        tid_dir = self.conf.addon_path + '/' + self._tid
 
         if self.conf.writable and not os.path.exists(tid_dir):
             try:
@@ -612,7 +619,6 @@ class YumHistory:
         # return
         return True
         
-            
 
     def _old_with_pkgs(self, tid):
         cur = self._get_cursor()
-- 
1.7.0.1



More information about the Yum-devel mailing list