Change in vdsm[master]: fileUtils: Remove unneeded else block

nsoffer at redhat.com nsoffer at redhat.com
Sun Jan 11 22:59:44 UTC 2015


Nir Soffer has uploaded a new change for review.

Change subject: fileUtils: Remove unneeded else block
......................................................................

fileUtils: Remove unneeded else block

The code is about handling existing directories, not about taking one of
two choices. Using early return on errors and keeping the normal code
path is more clear.

Change-Id: I67f043ce6b9fac2e980d0e94ef638a5eabfc2c7a
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm/storage/fileUtils.py
1 file changed, 10 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/79/36779/1

diff --git a/vdsm/storage/fileUtils.py b/vdsm/storage/fileUtils.py
index 95f7682..45ba75c 100644
--- a/vdsm/storage/fileUtils.py
+++ b/vdsm/storage/fileUtils.py
@@ -145,17 +145,16 @@
     except OSError as e:
         if e.errno != errno.EEXIST:
             raise
-        else:
-            log.debug("Using existing directory: %s", dirPath)
-            if mode is not None:
-                statinfo = os.stat(dirPath)
-                curMode = statinfo[stat.ST_MODE]
-                if curMode != mode:
-                    raise OSError(errno.EPERM,
-                                  ("Existing %s permissions %s are not as "
-                                   "requested %s") % (dirPath,
-                                                      oct(curMode),
-                                                      oct(mode)))
+        log.debug("Using existing directory: %s", dirPath)
+        if mode is not None:
+            statinfo = os.stat(dirPath)
+            curMode = statinfo[stat.ST_MODE]
+            if curMode != mode:
+                raise OSError(errno.EPERM,
+                              ("Existing %s permissions %s are not as "
+                               "requested %s") % (dirPath,
+                                                  oct(curMode),
+                                                  oct(mode)))
 
 
 def resolveUid(user):


-- 
To view, visit http://gerrit.ovirt.org/36779
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I67f043ce6b9fac2e980d0e94ef638a5eabfc2c7a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list