commit:     8817de9e401e9207036baa514b248baf749fe524
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 17 21:59:40 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Jun 19 03:49:58 2014 +0000
URL:        
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=8817de9e

layman_.py: Adds checks to ensure repo location

Previously it was made so that the initialization of the LaymanAPI
wouldn't occur if it already existed. This could however lead to
reporting the incorrect storage location for repositories reported
by repos.conf. Checks have been added to ensure that the LaymanAPI
will be re-initialized if the storage location reported by repos.conf
differs from what was already previously reported.

---
 layman/layman_/layman_.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/layman/layman_/layman_.py b/layman/layman_/layman_.py
index b24f33f..510e3aa 100644
--- a/layman/layman_/layman_.py
+++ b/layman/layman_/layman_.py
@@ -123,17 +123,25 @@ class PyLayman(SyncBase):
         SyncBase.__init__(self, 'layman', 'app-portage/layman')
 
         self._layman = None
+        self.storage = ''
+        self.current_storage = ''
 
 
     def _get_layman_api(self):
 
         # Make it so that we aren't initializing the
-        # LaymanAPI instance if it already exists.
-        if self._layman:
+        # LaymanAPI instance if it already exists and
+        # if the current storage location hasn't been
+        # changed for the new repository.
+        self.storage = self.repo.location.replace(self.repo.name, '')
+
+        if self._layman and self.storage in self.current_storage:
             return self._layman
 
         config = BareConfig()
+
         self.message = Message(out=sys.stdout, err=sys.stderr)
+        self.current_storage = self.storage
 
         options = {
             'config': config.get_option('config'),
@@ -142,7 +150,7 @@ class PyLayman(SyncBase):
             'output': self.message,
             'nocolor': self.settings.get('NOCOLOR'),
             'root': self.settings.get('EROOT'),
-            'storage': self.repo.location.replace(self.repo.name, ''),
+            'storage': self.current_storage,
             'verbose': self.settings.get('PORTAGE_VERBOSE'),
             'width': self.settings.get('COLUMNWIDTH'),
 

Reply via email to