Commit e1d6b628 authored by David Douard's avatar David Douard
Browse files

[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).

--HG--
branch : 3.25
parent b5be819872bb
......@@ -39,6 +39,17 @@ except ImportError:
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 @@ class GenStaticDataDirMixIn(object):
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()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment