Revision cddcf432 pithos/api/functions.py

b/pithos/api/functions.py
51 51
    update_manifest_meta, update_sharing_meta, update_public_meta, validate_modification_preconditions,
52 52
    validate_matching_preconditions, split_container_object_string, copy_or_move_object,
53 53
    get_int_parameter, get_content_length, get_content_range, socket_read_iterator, SaveToBackendHandler,
54
    object_data_response, put_object_block, hashmap_hash, api_method, json_encode_decimal)
54
    object_data_response, put_object_block, hashmap_md5, api_method, json_encode_decimal)
55 55
from pithos.backends.base import NotAllowedError, QuotaError
56 56

  
57 57

  
......
829 829
                    hashmap.append(hash.firstChild.data)
830 830
            except:
831 831
                raise BadRequest('Invalid data formatting')
832
        
833
        meta.update({'ETag': hashmap_hash(request, hashmap)}) # Update ETag.
834 832
    else:
835 833
        md5 = hashlib.md5()
836 834
        size = 0
......
864 862
        raise Conflict('\n'.join(e.data) + '\n')
865 863
    except QuotaError:
866 864
        raise RequestEntityTooLarge('Quota exceeded')
865
    if 'ETag' not in meta:
866
        # Update the MD5 after the hashmap, as there may be missing hashes.
867
        # TODO: This will create a new version, even if done synchronously...
868
        etag = hashmap_md5(request, hashmap, size)
869
        meta.update({'ETag': etag}) # Update ETag.
870
        try:
871
            version_id = request.backend.update_object_meta(request.user_uniq,
872
                            v_account, v_container, v_object, 'pithos', {'ETag': etag}, False)
873
        except NotAllowedError:
874
            raise Forbidden('Not allowed')
867 875
    if public is not None:
868 876
        try:
869 877
            request.backend.update_object_public(request.user_uniq, v_account,
......
1170 1178
    if dest_bytes is not None and dest_bytes < size:
1171 1179
        size = dest_bytes
1172 1180
        hashmap = hashmap[:(int((size - 1) / request.backend.block_size) + 1)]
1173
    meta.update({'ETag': hashmap_hash(request, hashmap)}) # Update ETag.
1181
    meta.update({'ETag': hashmap_md5(request, hashmap, size)}) # Update ETag.
1174 1182
    try:
1175 1183
        version_id = request.backend.update_object_hashmap(request.user_uniq,
1176 1184
                        v_account, v_container, v_object, size, hashmap,

Also available in: Unified diff