Revision 33b4e4a6 pithos/api/util.py
b/pithos/api/util.py | ||
---|---|---|
183 | 183 |
return content_type, meta, get_sharing(request), get_public(request) |
184 | 184 |
|
185 | 185 |
def put_object_headers(response, meta, restricted=False): |
186 |
if 'ETag' in meta: |
|
187 |
response['ETag'] = meta['ETag'] |
|
186 |
response['ETag'] = meta['checksum'] |
|
188 | 187 |
response['Content-Length'] = meta['bytes'] |
189 | 188 |
response['Content-Type'] = meta.get('type', 'application/octet-stream') |
190 | 189 |
response['Last-Modified'] = http_date(int(meta['modified'])) |
... | ... | |
219 | 218 |
for x in objects: |
220 | 219 |
src_meta = request.backend.get_object_meta(request.user_uniq, |
221 | 220 |
v_account, src_container, x[0], 'pithos', x[1]) |
222 |
if 'ETag' in src_meta: |
|
223 |
etag += src_meta['ETag'] |
|
221 |
etag += src_meta['checksum'] |
|
224 | 222 |
bytes += src_meta['bytes'] |
225 | 223 |
except: |
226 | 224 |
# Ignore errors. |
... | ... | |
228 | 226 |
meta['bytes'] = bytes |
229 | 227 |
md5 = hashlib.md5() |
230 | 228 |
md5.update(etag) |
231 |
meta['ETag'] = md5.hexdigest().lower()
|
|
229 |
meta['checksum'] = md5.hexdigest().lower()
|
|
232 | 230 |
|
233 | 231 |
def update_sharing_meta(request, permissions, v_account, v_container, v_object, meta): |
234 | 232 |
if permissions is None: |
... | ... | |
275 | 273 |
def validate_matching_preconditions(request, meta): |
276 | 274 |
"""Check that the ETag conforms with the preconditions set.""" |
277 | 275 |
|
278 |
etag = meta.get('ETag', None) |
|
276 |
etag = meta['checksum'] |
|
277 |
if not etag: |
|
278 |
etag = None |
|
279 | 279 |
|
280 | 280 |
if_match = request.META.get('HTTP_IF_MATCH') |
281 | 281 |
if if_match is not None: |
... | ... | |
713 | 713 |
ranges = [(0, size)] |
714 | 714 |
ret = 200 |
715 | 715 |
except ValueError: |
716 |
if if_range != meta['ETag']:
|
|
716 |
if if_range != meta['checksum']:
|
|
717 | 717 |
ranges = [(0, size)] |
718 | 718 |
ret = 200 |
719 | 719 |
|
Also available in: Unified diff