From 725a7b2f59a296467439edde5aab75dc9552e60d Mon Sep 17 00:00:00 2001 From: verm666 Date: Fri, 26 Jun 2015 05:49:59 -0700 Subject: [PATCH 1/2] unarchive: fix work with 0 bytes archives This change is in response to issue #1575 --- files/unarchive.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/files/unarchive.py b/files/unarchive.py index 8053991b63d..a3544253402 100644 --- a/files/unarchive.py +++ b/files/unarchive.py @@ -300,6 +300,16 @@ def main(): if not os.access(src, os.R_OK): module.fail_json(msg="Source '%s' not readable" % src) + # skip working with 0 size archives + try: + if os.path.getsize(src) == 0: + res_args = { + 'changed': False + } + module.exit_json(**res_args) + except Exception, e: + module.fail_json(msg="Source '%s' not readable" % src) + # is dest OK to receive tar file? if not os.path.isdir(dest): module.fail_json(msg="Destination '%s' is not a directory" % dest) From 8deee99fcc72852e7275746c2793976790881d50 Mon Sep 17 00:00:00 2001 From: verm666 Date: Tue, 30 Jun 2015 08:14:30 -0700 Subject: [PATCH 2/2] unarchive: fix @bcoca's remarks, issue #1575 --- files/unarchive.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/files/unarchive.py b/files/unarchive.py index a3544253402..3ee83de0dcd 100644 --- a/files/unarchive.py +++ b/files/unarchive.py @@ -303,10 +303,7 @@ def main(): # skip working with 0 size archives try: if os.path.getsize(src) == 0: - res_args = { - 'changed': False - } - module.exit_json(**res_args) + module.fail_json(msg="Invalid archive '%s', the file is 0 bytes" % src) except Exception, e: module.fail_json(msg="Source '%s' not readable" % src)