From d89d2432fd77ec1bdb08c0e5280d107b500f55c0 Mon Sep 17 00:00:00 2001 From: Cristian Ciupitu Date: Fri, 28 Mar 2014 22:47:46 +0200 Subject: [PATCH] Bugfix for gc_storage and s3 Make keysum return None if not key_check (this case wasn't covered). --- library/cloud/gc_storage | 11 ++++++----- library/cloud/s3 | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/library/cloud/gc_storage b/library/cloud/gc_storage index 4bbf9eabae7..8696f8e965d 100644 --- a/library/cloud/gc_storage +++ b/library/cloud/gc_storage @@ -152,11 +152,12 @@ def key_check(module, gs, bucket, obj): def keysum(module, gs, bucket, obj): bucket = gs.lookup(bucket) key_check = bucket.get_key(obj) - if key_check: - md5_remote = key_check.etag[1:-1] - etag_multipart = '-' in md5_remote # Check for multipart, etag is not md5 - if etag_multipart is True: - module.fail_json(msg="Files uploaded with multipart of gs are not supported with checksum, unable to compute checksum.") + if not key_check: + return None + md5_remote = key_check.etag[1:-1] + etag_multipart = '-' in md5_remote # Check for multipart, etag is not md5 + if etag_multipart is True: + module.fail_json(msg="Files uploaded with multipart of gs are not supported with checksum, unable to compute checksum.") return md5_remote def bucket_check(module, gs, bucket): diff --git a/library/cloud/s3 b/library/cloud/s3 index aaa2e0f4ffb..715c0e00ab9 100644 --- a/library/cloud/s3 +++ b/library/cloud/s3 @@ -145,11 +145,12 @@ def key_check(module, s3, bucket, obj): def keysum(module, s3, bucket, obj): bucket = s3.lookup(bucket) key_check = bucket.get_key(obj) - if key_check: - md5_remote = key_check.etag[1:-1] - etag_multipart = '-' in md5_remote # Check for multipart, etag is not md5 - if etag_multipart is True: - module.fail_json(msg="Files uploaded with multipart of s3 are not supported with checksum, unable to compute checksum.") + if not key_check: + return None + md5_remote = key_check.etag[1:-1] + etag_multipart = '-' in md5_remote # Check for multipart, etag is not md5 + if etag_multipart is True: + module.fail_json(msg="Files uploaded with multipart of s3 are not supported with checksum, unable to compute checksum.") return md5_remote def bucket_check(module, s3, bucket):