mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
unarchive: fix work with 0 bytes archives
This change is in response to issue #1575
This commit is contained in:
parent
db646757c1
commit
b898cb656b
1 changed files with 10 additions and 0 deletions
|
@ -300,6 +300,16 @@ def main():
|
||||||
if not os.access(src, os.R_OK):
|
if not os.access(src, os.R_OK):
|
||||||
module.fail_json(msg="Source '%s' not readable" % src)
|
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?
|
# is dest OK to receive tar file?
|
||||||
if not os.path.isdir(dest):
|
if not os.path.isdir(dest):
|
||||||
module.fail_json(msg="Destination '%s' is not a directory" % dest)
|
module.fail_json(msg="Destination '%s' is not a directory" % dest)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue