Blame SOURCES/BZ-1095157-traceback-when-empty-history.patch

65829f
commit 1c557629752d26dca86948c5e933d8f31448818d
65829f
Author: Valentina Mukhamedzhanova <vmukhame@redhat.com>
65829f
Date:   Thu Apr 17 16:15:22 2014 +0200
65829f
65829f
    Fix traceback when the history dir is empty. BZ 875610
65829f
65829f
diff --git a/yum/history.py b/yum/history.py
65829f
index 3f20128..2f423d9 100644
65829f
--- a/yum/history.py
65829f
+++ b/yum/history.py
65829f
@@ -697,7 +697,9 @@ class YumHistory:
65829f
             break
65829f
 
65829f
         if self._db_file is None:
65829f
-            self._create_db_file()
65829f
+            if not self._create_db_file():
65829f
+                # Couldn't create a db file
65829f
+                return
65829f
         
65829f
         # make an addon path for where we're going to stick 
65829f
         # random additional history info - probably from plugins and what-not
65829f
@@ -1603,8 +1605,10 @@ class YumHistory:
65829f
             if os.path.exists(_db_file + '-journal'):
65829f
                 os.rename(_db_file  + '-journal', _db_file + '-journal.old')
65829f
         self._db_file = _db_file
65829f
+        if not self.conf.writable:
65829f
+            return False
65829f
         
65829f
-        if self.conf.writable and not os.path.exists(self._db_file):
65829f
+        if not os.path.exists(self._db_file):
65829f
             # make them default to 0600 - sysadmin can change it later
65829f
             # if they want
65829f
             fo = os.open(self._db_file, os.O_CREAT, 0600)
65829f
@@ -1659,6 +1663,7 @@ class YumHistory:
65829f
         for op in self._update_ops_3:
65829f
             cur.execute(op)
65829f
         self._commit()
65829f
+        return True
65829f
 
65829f
 # Pasted from sqlitesack
65829f
 _FULL_PARSE_QUERY_BEG = """
65829f
commit 8c6cd83a4825155d1ee9ddcd29b023682944e3e6
65829f
Author: Valentina Mukhamedzhanova <vmukhame@redhat.com>
65829f
Date:   Wed Mar 12 15:41:30 2014 +0100
65829f
65829f
    Fix traceback when history files don't exist and user is not root.
65829f
65829f
diff --git a/yum/history.py b/yum/history.py
65829f
index 6f60f54..3f20128 100644
65829f
--- a/yum/history.py
65829f
+++ b/yum/history.py
65829f
@@ -668,6 +668,7 @@ class YumHistory:
65829f
 
65829f
         self.releasever = releasever
65829f
 
65829f
+        self._db_file = None
65829f
         if not os.path.exists(self.conf.db_path):
65829f
             try:
65829f
                 os.makedirs(self.conf.db_path)
65829f
@@ -680,7 +681,6 @@ class YumHistory:
65829f
                 self.conf.writable = True
65829f
 
65829f
         DBs = glob.glob('%s/history-*-*-*.sqlite' % self.conf.db_path)
65829f
-        self._db_file = None
65829f
         for d in reversed(sorted(DBs)):
65829f
             fname = os.path.basename(d)
65829f
             fname = fname[len("history-"):-len(".sqlite")]
65829f
diff --git a/yumcommands.py b/yumcommands.py
65829f
index 4e72a71..75b3ce2 100644
65829f
--- a/yumcommands.py
65829f
+++ b/yumcommands.py
65829f
@@ -3051,7 +3051,7 @@ class HistoryCommand(YumCommand):
65829f
         if extcmds and extcmds[0] in ('repeat', 'redo', 'undo', 'rollback', 'new'):
65829f
             checkRootUID(base)
65829f
             checkGPGKey(base)
65829f
-        elif not os.access(base.history._db_file, os.R_OK):
65829f
+        elif not (base.history._db_file and os.access(base.history._db_file, os.R_OK)):
65829f
             base.logger.critical(_("You don't have access to the history DB."))
65829f
             raise cli.CliError
65829f