Revision 133e3fcf snf-pithos-app/pithos/api/manage_accounts/__init__.py

b/snf-pithos-app/pithos/api/manage_accounts/__init__.py
31 31
# interpreted as representing official policies, either expressed
32 32
# or implied, of GRNET S.A.
33 33

  
34
from pithos.api.util import get_backend, split_container_object_string
35

  
34
from pithos.api.util import (
35
    get_backend, split_container_object_string, Checksum, NoChecksum
36
)
36 37
import re
37
import hashlib
38 38
import os
39 39

  
40 40

  
......
307 307
        return self.backend._lookup_account(account, create=True)
308 308

  
309 309
    def create_update_object(self, account, container, name, content_type,
310
                             data, meta=None, permissions=None, request_user=None):
310
                             data, meta=None, permissions=None,
311
                             request_user=None,
312
                             checksum_compute_class=NoChecksum):
311 313
        meta = meta or {}
312 314
        permissions = permissions or {}
313
        md5 = hashlib.md5()
315

  
316
        assert checksum_compute_class in (NoChecksum, Checksum), 'Invalid checksum_compute_class'
317
        checksum_compute = checksum_compute_class()
314 318
        size = 0
315 319
        hashmap = []
316 320
        for block_data in data_read_iterator(data, self.backend.block_size):
317 321
            size += len(block_data)
318 322
            hashmap.append(self.backend.put_block(block_data))
319
            md5.update(block_data)
323
            checksum_compute.update(block_data)
320 324

  
321
        checksum = md5.hexdigest().lower()
325
        checksum = checksum_compute.hexdigest()
322 326

  
323 327
        request_user = request_user or account
324 328
        return self.backend.update_object_hashmap(request_user, account,

Also available in: Unified diff