archive: Fix check if archive is created in path to be removed (#29420)

pull/50613/head
feran 6 years ago committed by Toshio Kuratomi
parent eb4249c7da
commit 1d3d6a3e2d

@ -261,8 +261,13 @@ def main():
arcroot += os.sep arcroot += os.sep
# Don't allow archives to be created anywhere within paths to be removed # Don't allow archives to be created anywhere within paths to be removed
if remove and os.path.isdir(path) and dest.startswith(path): if remove and os.path.isdir(path):
module.fail_json(path=', '.join(paths), msg='Error, created archive can not be contained in source paths when remove=True') path_dir = path
if path[-1] != '/':
path_dir += '/'
if dest.startswith(path_dir):
module.fail_json(path=', '.join(paths), msg='Error, created archive can not be contained in source paths when remove=True')
if os.path.lexists(path) and path not in expanded_exclude_paths: if os.path.lexists(path) and path not in expanded_exclude_paths:
archive_paths.append(path) archive_paths.append(path)

Loading…
Cancel
Save