You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2012/11/22 01:56:31 UTC
svn commit: r1412399 - /libcloud/trunk/libcloud/storage/drivers/local.py
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