libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1412399 - /libcloud/trunk/libcloud/storage/drivers/local.py
Date Thu, 22 Nov 2012 00:56:31 GMT
Author: tomaz
Date: Thu Nov 22 00:56:30 2012
New Revision: 1412399

URL: http://svn.apache.org/viewvc?rev=1412399&view=rev
Log:
Improve empty directory handling in the local storage storage driver.

Contributed by Mahendra M, part of LIBCLOUD-265.

Modified:
    libcloud/trunk/libcloud/storage/drivers/local.py

Modified: libcloud/trunk/libcloud/storage/drivers/local.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/storage/drivers/local.py?rev=1412399&r1=1412398&r2=1412399&view=diff
==============================================================================
--- libcloud/trunk/libcloud/storage/drivers/local.py (original)
+++ libcloud/trunk/libcloud/storage/drivers/local.py Thu Nov 22 00:56:30 2012
@@ -508,14 +508,21 @@ class LocalStorageDriver(StorageDriver):
             except Exception:
                 return False
 
-        # Check and delete the folder if required
+        # Check and delete all the empty parent folders
         path = os.path.dirname(path)
+        container_url = obj.container.get_cdn_url()
 
-        try:
-            if path != obj.container.get_cdn_url():
+        # Delete the empty parent folders till the container's level
+        while path != container_url:
+            try:
                 os.rmdir(path)
-        except Exception:
-            pass
+            except OSError:
+                exp = sys.exc_info()[1]
+                if exp.errno == errno.ENOTEMPTY:
+                    break
+                raise exp
+
+            path = os.path.dirname(path)
 
         return True
 



Mime
View raw message