Make checksum updates optional.
authorAntony Chazapis <chazapis@gmail.com>
Mon, 2 Apr 2012 22:46:23 +0000 (01:46 +0300)
committerAntony Chazapis <chazapis@gmail.com>
Mon, 2 Apr 2012 22:46:23 +0000 (01:46 +0300)
Refs #1792

snf-pithos-app/README
snf-pithos-app/conf/20-snf-pithos-app-settings.conf
snf-pithos-app/pithos/api/functions.py
snf-pithos-app/pithos/api/settings.py

index 85a5884..2921482 100644 (file)
@@ -40,6 +40,7 @@ PITHOS_BACKEND_QUEUE_MODULE      None
 PITHOS_BACKEND_QUEUE_CONNECTION  None                                              Format like ``rabbitmq://guest:guest@localhost:5672/pithos``
 PITHOS_BACKEND_QUOTA             50 GB (50 * 1024 ** 3)                            Default user quota
 PITHOS_BACKEND_VERSIONING        auto                                              Default versioning policy for containers
+PITHOS_UPDATE_MD5                True                                              Update object checksums when using hashmaps
 ===============================  ================================================  ============================================================
 
 Administrator functions
index 836df30..3ed94c7 100644 (file)
@@ -27,3 +27,5 @@ PITHOS_BACKEND_BLOCK_PATH = '/usr/share/synnefo/pithos/data'
 #PITHOS_BACKEND_QUOTA = 50 * 1024 * 1024 * 1024
 #PITHOS_BACKEND_VERSIONING = 'auto'
 
+# Disable if checksums are not required or are computed asynchronously by an external process.
+#PITHOS_UPDATE_MD5 = True
index 0010f91..521b28f 100644 (file)
@@ -52,7 +52,7 @@ from pithos.api.util import (json_encode_decimal, rename_meta_key, format_header
     validate_modification_preconditions, validate_matching_preconditions, split_container_object_string,
     copy_or_move_object, get_int_parameter, get_content_length, get_content_range, socket_read_iterator,
     SaveToBackendHandler, object_data_response, put_object_block, hashmap_md5, simple_list_response, api_method)
-from pithos.api.settings import AUTHENTICATION_URL, AUTHENTICATION_USERS, COOKIE_NAME
+from pithos.api.settings import AUTHENTICATION_URL, AUTHENTICATION_USERS, COOKIE_NAME, UPDATE_MD5
 
 from pithos.backends.base import NotAllowedError, QuotaError
 from pithos.backends.filter import parse_filters
@@ -884,7 +884,7 @@ def object_write(request, v_account, v_container, v_object):
         raise BadRequest('Invalid sharing header')
     except QuotaError:
         raise RequestEntityTooLarge('Quota exceeded')
-    if not checksum:
+    if not checksum and UPDATE_MD5:
         # Update the MD5 after the hashmap, as there may be missing hashes.
         checksum = hashmap_md5(request, hashmap, size)
         try:
@@ -1187,7 +1187,7 @@ def object_update(request, v_account, v_container, v_object):
     if dest_bytes is not None and dest_bytes < size:
         size = dest_bytes
         hashmap = hashmap[:(int((size - 1) / request.backend.block_size) + 1)]
-    checksum = hashmap_md5(request, hashmap, size)
+    checksum = hashmap_md5(request, hashmap, size) if UPDATE_MD5 else ''
     try:
         version_id = request.backend.update_object_hashmap(request.user_uniq,
                         v_account, v_container, v_object, size, prev_meta['type'],
index 1558bfb..78aa47d 100644 (file)
@@ -36,3 +36,6 @@ BACKEND_QUEUE_CONNECTION = getattr(settings, 'PITHOS_BACKEND_QUEUE_CONNECTION',
 BACKEND_QUOTA = getattr(settings, 'PITHOS_BACKEND_QUOTA', 50 * 1024 * 1024 * 1024)
 BACKEND_VERSIONING = getattr(settings, 'PITHOS_BACKEND_VERSIONING', 'auto')
 
+# Update object checksums when using hashmaps.
+UPDATE_MD5 = getattr(settings, 'PITHOS_UPDATE_MD5', True)
+