Merge branch 'copy-diff-take2' of git://github.com/stoned/ansible into better_diff

Conflicts:
	library/file
This commit is contained in:
Michael DeHaan 2013-02-26 20:51:32 -05:00
commit 113db71bf6

14
file
View file

@ -141,6 +141,7 @@ def main():
state = dict(choices=['file','directory','link','absent'], default='file'), state = dict(choices=['file','directory','link','absent'], default='file'),
path = dict(aliases=['dest', 'name'], required=True), path = dict(aliases=['dest', 'name'], required=True),
recurse = dict(default='no', type='bool') recurse = dict(default='no', type='bool')
diff_peek = dict(default=None)
), ),
add_file_common_args=True, add_file_common_args=True,
supports_check_mode=True supports_check_mode=True
@ -150,6 +151,19 @@ def main():
state = params['state'] state = params['state']
params['path'] = path = os.path.expanduser(params['path']) params['path'] = path = os.path.expanduser(params['path'])
# short-circuit for diff_peek
if params.get('diff_peek', None) is not None:
appears_binary = False
try:
f = open(path)
b = f.read(8192)
f.close()
if b.find("\x00") != -1:
appears_binary = True
except:
pass
module.exit_json(path=path, changed=False, appears_binary=appears_binary)
# source is both the source of a symlink or an informational passing of the src for a template module # source is both the source of a symlink or an informational passing of the src for a template module
# or copy module, even if this module never uses it, it is needed to key off some things # or copy module, even if this module never uses it, it is needed to key off some things