File raise-an-error-about-failing-to-change-the-dbroot-value-only-if-the-directory-does-not-exist of Package python-rtslib-fb.9370

From: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
Date: Tue, 22 Aug 2017 13:50:53 +0200
Subject: Raise an error about failing to change the dbroot value only if the
 directory does not exist
Git-commit: 7b879d4c578ec50cf0a2596e2583846c7b397f52
Patch-mainline: v2.1.fb65

This allows targetcli to start when the dbroot value cannot be changed
because the target drivers are already registered (issue #105).

Signed-off-by: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
Acked-by: Lee Duncan <lduncan@suse.com>
---
 rtslib/root.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/rtslib/root.py b/rtslib/root.py
index e1d51168238d..0c3c2313800c 100644
--- a/rtslib/root.py
+++ b/rtslib/root.py
@@ -167,8 +167,9 @@ class RTSRoot(CFSNode):
             try:
                 fwrite(dbroot_path, self._preferred_dbroot+"\n")
             except:
-                raise RTSLibError("Cannot set dbroot to {}. Please check if this directory exists."
-                                  .format(self._preferred_dbroot))
+                if not os.path.isdir(self._preferred_dbroot):
+                    raise RTSLibError("Cannot set dbroot to {}. Please check if this directory exists."
+                                      .format(self._preferred_dbroot))
             self._dbroot = fread(dbroot_path)
 
     def _get_dbroot(self):

openSUSE Build Service is sponsored by