# HG changeset patch # User David Douard # Date 1491298883 -7200 # Node ID 20035170160c0e6891afa5f8485e22bcf7dd405f # Parent b5be819872bbb35a52f5feb45c1708ffab59e06c [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). diff -r b5be819872bb -r 20035170160c cubicweb/web/webctl.py --- 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()