Commit 76ab5558 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

backend: Add optional exclusion list to _CleanDirectory

The code cleaning the queue will make use of it.

Reviewed-by: iustinp
parent abc1f2ce
......@@ -48,11 +48,23 @@ def _GetSshRunner():
return ssh.SshRunner()
def _CleanDirectory(path):
def _CleanDirectory(path, exclude=[]):
"""Removes all regular files in a directory.
@param exclude: List of files to be excluded.
@type exclude: list
"""
if not os.path.isdir(path):
return
# Normalize excluded paths
exclude = [os.path.normpath(i) for i in exclude]
for rel_name in utils.ListVisibleFiles(path):
full_name = os.path.join(path, rel_name)
full_name = os.path.normpath(os.path.join(path, rel_name))
if full_name in exclude:
continue
if os.path.isfile(full_name) and not os.path.islink(full_name):
utils.RemoveFile(full_name)
......
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