[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH master] After cancelled stage 2 network enablement remove temporary repo (#623639)



When adding a repository requiring network enablement, we should
remove temporary repo object if the enablement failed. Otherwise
we can run into duplicate repos error (causing the traceback at the
moment) in next try.
---
 pyanaconda/iw/task_gui.py |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/pyanaconda/iw/task_gui.py b/pyanaconda/iw/task_gui.py
index 8f9fac0..cba030d 100644
--- a/pyanaconda/iw/task_gui.py
+++ b/pyanaconda/iw/task_gui.py
@@ -57,9 +57,6 @@ def setupRepo(anaconda, repo):
                 "Please ensure that your repository has been "
                 "correctly generated.\n\n%s" % str(e)),
                                 type="ok", custom_icon="error")
-        repo.disable()
-        repo.close()
-        anaconda.backend.ayum.repos.delete(repo.id)
         return False
 
     return True
@@ -161,6 +158,12 @@ class RepoEditor:
         repo.enable()
         return True
 
+    def _disableAndRemoveRepo(self, repo):
+        repo.disable()
+        repo.close()
+        self.anaconda.backend.ayum.repos.delete(repo.id)
+
+
     def _validURL(self, url):
         return len(url) > 0 and (url.startswith("http://";) or
                                  url.startswith("https://";) or
@@ -365,8 +368,11 @@ class RepoEditor:
             newRepoObj.basecachedir = self.anaconda.backend.ayum.conf.cachedir
 
             type = self.typeComboBox.get_active()
-            if not applyFuncs[type](newRepoObj) or not self._addAndEnableRepo(newRepoObj) or not \
-                   setupRepo(self.anaconda, newRepoObj):
+            if (not applyFuncs[type](newRepoObj) or
+                not self._addAndEnableRepo(newRepoObj)):
+                continue
+            if not setupRepo(self.anaconda, newRepoObj):
+                self._disableAndRemoveRepo(newRepoObj)
                 continue
 
             if removeOld:
@@ -589,6 +595,8 @@ class TaskWindow(InstallWindow):
 
             repo.enable()
             if not setupRepo(self.anaconda, repo):
+                repo.disable()
+                repo.close()
                 return
         else:
             repo.disable()
-- 
1.7.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]