1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Tar --diff only sends output to stderr if a file is missing. Handle that case

Fixes #1064
This commit is contained in:
Toshio Kuratomi 2015-04-15 05:05:41 -07:00 committed by Matt Clay
parent 5a0a9d9f72
commit 02b8e17f61

View file

@ -75,9 +75,14 @@ EXAMPLES = '''
- unarchive: src=/tmp/foo.zip dest=/usr/local/bin copy=no
'''
import re
import os
from zipfile import ZipFile
# String from tar that shows the tar contents are different from the
# filesystem
DIFFERENCE_RE = re.compile(r': (.*) differs$')
class UnarchiveError(Exception):
pass
@ -168,9 +173,12 @@ class TgzArchive(object):
# What is different
changes = set()
difference_re = re.compile(r': (.*) differs$')
if err:
# Assume changes if anything returned on stderr
# * Missing files are known to trigger this
return dict(unarchived=unarchived, rc=rc, out=out, err=err, cmd=cmd)
for line in out.splitlines():
match = difference_re.search(line)
match = DIFFERENCE_RE.search(line)
if not match:
# Unknown tar output. Assume we have changes
return dict(unarchived=unarchived, rc=rc, out=out, err=err, cmd=cmd)