summaryrefslogtreecommitdiff
path: root/swiftclient
diff options
context:
space:
mode:
authorTim Burke <tim.burke@gmail.com>2023-03-10 09:22:34 -0800
committerTim Burke <tim.burke@gmail.com>2023-03-14 11:56:03 -0700
commit6adb8bb17fe55a33d3605944653ca956eabc9ece (patch)
treea9063c9b4ee681201cd1d7b421f59298ca6560a9 /swiftclient
parent0f2b567953c9cdcd566eff30d15aefa717ee47db (diff)
downloadpython-swiftclient-6adb8bb17fe55a33d3605944653ca956eabc9ece.tar.gz
service: Check content-length before etag
If the received content-length does not match expectations, of course the etag won't match! Co-Authored-By: Alistair Coles <alistairncoles@gmail.com> Change-Id: I1a0c066c11b94718fffbb11e13b82d0b16e01626
Diffstat (limited to 'swiftclient')
-rw-r--r--swiftclient/service.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/swiftclient/service.py b/swiftclient/service.py
index 9a6c7a1..d1c98d6 100644
--- a/swiftclient/service.py
+++ b/swiftclient/service.py
@@ -457,13 +457,6 @@ class _SwiftReader:
self._check_contents()
def _check_contents(self):
- if self._actual_md5 and self._expected_md5:
- etag = self._actual_md5.hexdigest()
- if etag != self._expected_md5:
- raise SwiftError('Error downloading {0}: md5sum != etag, '
- '{1} != {2}'.format(
- self._path, etag, self._expected_md5))
-
if (self._content_length is not None and
self._actual_read != self._content_length):
raise SwiftError('Error downloading {0}: read_length != '
@@ -471,6 +464,13 @@ class _SwiftReader:
self._path, self._actual_read,
self._content_length))
+ if self._actual_md5 and self._expected_md5:
+ etag = self._actual_md5.hexdigest()
+ if etag != self._expected_md5:
+ raise SwiftError('Error downloading {0}: md5sum != etag, '
+ '{1} != {2}'.format(
+ self._path, etag, self._expected_md5))
+
def bytes_read(self):
return self._actual_read