X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tools.py;h=b6a189ad0f1fa68039bb89f559599eeea5ffe6f2;hb=91077a5b37a3a3eec3c05e1d67b6a68efa75063a;hp=e37c0d5e327a79130e1ef940e480cc1c381266da;hpb=6aeeb0a49f3f2fbaad74adbbe9dc52be74eb204d;p=nodemanager.git diff --git a/tools.py b/tools.py index e37c0d5..b6a189a 100644 --- a/tools.py +++ b/tools.py @@ -133,7 +133,8 @@ def replace_file_with_string (target, new_contents, chmod=None, remove_if_empty= if current==new_contents: # if turns out to be an empty string, and remove_if_empty is set, # then make sure to trash the file if it exists - if remove_if_empty and os.path.isfile(target): + if remove_if_empty and not new_contents and os.path.isfile(target): + logger.verbose("tools.replace_file_with_string: removing file %s"%target) try: os.unlink(target) finally: return True return False