[cwctl] do only clean static data dir content (closes #17069762)
deleting the directory itself is useless and may be a problem in automated
deployment environments (user may not have permissions to delete or create
that directory).
--- a/cubicweb/web/webctl.py Mon Apr 03 14:43:44 2017 +0200
+++ b/cubicweb/web/webctl.py Tue Apr 04 11:41:23 2017 +0200
@@ -39,6 +39,17 @@
from shutil import copytree as linkdir
+def rmtreecontent(dst):
+ """Delete the content of the dst directory (but NOT the directory
+ itself)"""
+ for fname in os.listdir(dst):
+ fpath = osp.join(dst, fname)
+ if osp.isfile(fpath):
+ os.unlink(fpath)
+ else:
+ rmtree(fpath)
+
+
class WebCreateHandler(CommandHandler):
cmdname = 'create'
@@ -70,7 +81,7 @@
ASK.confirm('Remove existing data directory %s?' % dest))):
raise ExecutionError('Directory %s already exists. '
'Remove it first.' % dest)
- rmtree(dest)
+ rmtreecontent(dest)
config.quick_start = True # notify this is not a regular start
# list all resources (no matter their order)
resources = set()