From 58d359ee6edc0cb182b0f59883a85f0233b5157b Mon Sep 17 00:00:00 2001 From: "Z. Liu" Date: Thu, 7 May 2015 15:30:53 +0800 Subject: [PATCH 1/3] add directory itself to keep list if not fixed, following sls will delete /root/a/b /root/a: file.directory: - user: root - group: root - mode: 0755 - clean: True - require: - file: /root/a/b /root/a/b: file.directory: - user: root - group: root - mode: 0755 --- salt/states/file.py | 1 + 1 file changed, 1 insertion(+) diff --git a/salt/states/file.py b/salt/states/file.py index 269e509fb0..eb37b343b1 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -337,6 +337,7 @@ def _gen_keep_files(name, require): ret = set() if os.path.isdir(name): for root, dirs, files in os.walk(name): + ret.add(name) for name in files: ret.add(os.path.join(root, name)) for name in dirs: From fe43c66997103399ee793357bad69844829151ab Mon Sep 17 00:00:00 2001 From: "Z. Liu" Date: Thu, 7 May 2015 16:20:02 +0800 Subject: [PATCH 2/3] another fix for file defined w/ id, but require name for following sls: /root/a: file.directory: - user: root - group: root - mode: 0755 - clean: True - require: - file: /root/a/b - file: /root/a/c /root/a/b: file.directory: - user: root - group: root - mode: 0755 id_test: file.managed: - name: /root/a/c - user: root - group: root - mode: 0755 - replace: False --- salt/states/file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/states/file.py b/salt/states/file.py index eb37b343b1..ddcaded627 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -349,7 +349,7 @@ def _gen_keep_files(name, require): required_files = [comp for comp in require if 'file' in comp] for comp in required_files: for low in __lowstate__: - if low['__id__'] == comp['file']: + if comp['file'] in (low['__id__'], low['name']): fn = low['name'] if os.path.isdir(comp['file']): if _is_child(comp['file'], name): From 65143dee8dbe05cdf8b2218c3ca17e66c26dd845 Mon Sep 17 00:00:00 2001 From: "Z. Liu" Date: Thu, 7 May 2015 16:29:32 +0800 Subject: [PATCH 3/3] check w/ low['name'] only --- salt/states/file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/states/file.py b/salt/states/file.py index ddcaded627..e9f6c18f57 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -349,7 +349,7 @@ def _gen_keep_files(name, require): required_files = [comp for comp in require if 'file' in comp] for comp in required_files: for low in __lowstate__: - if comp['file'] in (low['__id__'], low['name']): + if low['name'] == comp['file']: fn = low['name'] if os.path.isdir(comp['file']): if _is_child(comp['file'], name):