Revision 4a1c29ea pithos/api/functions.py
b/pithos/api/functions.py | ||
---|---|---|
532 | 532 |
except NameError: |
533 | 533 |
pass |
534 | 534 |
else: |
535 |
rename_meta_key(meta, 'hash', 'x_object_hash') # Will be replaced by ETag. |
|
536 |
rename_meta_key(meta, 'ETag', 'hash') |
|
535 | 537 |
rename_meta_key(meta, 'modified', 'last_modified') |
536 | 538 |
rename_meta_key(meta, 'modified_by', 'x_object_modified_by') |
537 | 539 |
rename_meta_key(meta, 'version', 'x_object_version') |
... | ... | |
584 | 586 |
validate_matching_preconditions(request, meta) |
585 | 587 |
except NotModified: |
586 | 588 |
response = HttpResponse(status=304) |
587 |
response['ETag'] = meta['hash']
|
|
589 |
response['ETag'] = meta['ETag']
|
|
588 | 590 |
return response |
589 | 591 |
|
590 | 592 |
response = HttpResponse(status=200) |
... | ... | |
653 | 655 |
validate_matching_preconditions(request, meta) |
654 | 656 |
except NotModified: |
655 | 657 |
response = HttpResponse(status=304) |
656 |
response['ETag'] = meta['hash']
|
|
658 |
response['ETag'] = meta['ETag']
|
|
657 | 659 |
return response |
658 | 660 |
|
659 | 661 |
sizes = [] |
... | ... | |
805 | 807 |
except: |
806 | 808 |
raise BadRequest('Invalid data formatting') |
807 | 809 |
|
808 |
meta.update({'hash': hashmap_hash(request, hashmap)}) # Update ETag.
|
|
810 |
meta.update({'ETag': hashmap_hash(request, hashmap)}) # Update ETag.
|
|
809 | 811 |
else: |
810 | 812 |
md5 = hashlib.md5() |
811 | 813 |
size = 0 |
... | ... | |
818 | 820 |
hashmap.append(request.backend.put_block(data)) |
819 | 821 |
md5.update(data) |
820 | 822 |
|
821 |
meta['hash'] = md5.hexdigest().lower()
|
|
823 |
meta['ETag'] = md5.hexdigest().lower()
|
|
822 | 824 |
etag = request.META.get('HTTP_ETAG') |
823 |
if etag and parse_etags(etag)[0].lower() != meta['hash']:
|
|
825 |
if etag and parse_etags(etag)[0].lower() != meta['ETag']:
|
|
824 | 826 |
raise UnprocessableEntity('Object ETag does not match') |
825 | 827 |
|
826 | 828 |
try: |
... | ... | |
849 | 851 |
raise ItemNotFound('Object does not exist') |
850 | 852 |
|
851 | 853 |
response = HttpResponse(status=201) |
852 |
response['ETag'] = meta['hash']
|
|
854 |
response['ETag'] = meta['ETag']
|
|
853 | 855 |
response['X-Object-Version'] = version_id |
854 | 856 |
return response |
855 | 857 |
|
... | ... | |
876 | 878 |
hashmap.append(request.backend.put_block(data)) |
877 | 879 |
md5.update(data) |
878 | 880 |
|
879 |
meta['hash'] = md5.hexdigest().lower()
|
|
881 |
meta['ETag'] = md5.hexdigest().lower()
|
|
880 | 882 |
|
881 | 883 |
try: |
882 | 884 |
version_id = request.backend.update_object_hashmap(request.user_uniq, |
... | ... | |
889 | 891 |
raise RequestEntityTooLarge('Quota exceeded') |
890 | 892 |
|
891 | 893 |
response = HttpResponse(status=201) |
892 |
response['ETag'] = meta['hash']
|
|
894 |
response['ETag'] = meta['ETag']
|
|
893 | 895 |
response['X-Object-Version'] = version_id |
894 | 896 |
return response |
895 | 897 |
|
... | ... | |
991 | 993 |
if request.META.get('HTTP_IF_MATCH') or request.META.get('HTTP_IF_NONE_MATCH'): |
992 | 994 |
validate_matching_preconditions(request, prev_meta) |
993 | 995 |
|
994 |
# If replacing, keep previous values of 'Content-Type' and 'hash'.
|
|
996 |
# If replacing, keep previous values of 'Content-Type' and 'ETag'.
|
|
995 | 997 |
replace = True |
996 | 998 |
if 'update' in request.GET: |
997 | 999 |
replace = False |
998 | 1000 |
if replace: |
999 |
for k in ('Content-Type', 'hash'):
|
|
1001 |
for k in ('Content-Type', 'ETag'):
|
|
1000 | 1002 |
if k in prev_meta: |
1001 | 1003 |
meta[k] = prev_meta[k] |
1002 | 1004 |
|
... | ... | |
1153 | 1155 |
if dest_bytes is not None and dest_bytes < size: |
1154 | 1156 |
size = dest_bytes |
1155 | 1157 |
hashmap = hashmap[:(int((size - 1) / request.backend.block_size) + 1)] |
1156 |
meta.update({'hash': hashmap_hash(request, hashmap)}) # Update ETag.
|
|
1158 |
meta.update({'ETag': hashmap_hash(request, hashmap)}) # Update ETag.
|
|
1157 | 1159 |
try: |
1158 | 1160 |
version_id = request.backend.update_object_hashmap(request.user_uniq, |
1159 | 1161 |
v_account, v_container, v_object, size, hashmap, meta, |
... | ... | |
1178 | 1180 |
raise ItemNotFound('Object does not exist') |
1179 | 1181 |
|
1180 | 1182 |
response = HttpResponse(status=204) |
1181 |
response['ETag'] = meta['hash']
|
|
1183 |
response['ETag'] = meta['ETag']
|
|
1182 | 1184 |
response['X-Object-Version'] = version_id |
1183 | 1185 |
return response |
1184 | 1186 |
|
Also available in: Unified diff