From 11ca9ba1ebb784fc3064c9c742a6408ccf4e6c96 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Wed, 5 Nov 2014 00:15:02 -0400 Subject: [PATCH] Issue #56, remove configurability of the checksum algorithm --- docs/topics/features.rst | 2 +- docs/topics/settings.rst | 9 --------- mayan/apps/documents/models.py | 6 +++--- mayan/apps/documents/settings.py | 7 ------- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/docs/topics/features.rst b/docs/topics/features.rst index c0b7cf5669..71cd8c5d4f 100644 --- a/docs/topics/features.rst +++ b/docs/topics/features.rst @@ -32,7 +32,7 @@ Features * If enabled, the document database index can be mirrored in the filesystem of the host and shared via Samba_ or any other sharing method to client computers on a network. -* User defined document unique identifier and checksum algorithms. +* User defined document unique identifier algorithms. * Users can alter the default method used to uniquely indentify documents. diff --git a/docs/topics/settings.rst b/docs/topics/settings.rst index 31b6eda67d..57cf207c1a 100644 --- a/docs/topics/settings.rst +++ b/docs/topics/settings.rst @@ -8,15 +8,6 @@ different server configurations. Documents ========= -.. setting:: DOCUMENTS_CHECKSUM_FUNCTION - -**DOCUMENTS_CHECKSUM_FUNCTION** - -Default: ``hashlib.sha256(x).hexdigest()`` - -The function that will be used to calculate the hash value of each uploaded document. - - .. setting:: DOCUMENTS_UUID_FUNCTION **DOCUMENTS_UUID_FUNCTION** diff --git a/mayan/apps/documents/models.py b/mayan/apps/documents/models.py index 9152678723..cff73ca208 100644 --- a/mayan/apps/documents/models.py +++ b/mayan/apps/documents/models.py @@ -35,8 +35,8 @@ from .literals import (LANGUAGE_CHOICES, VERSION_UPDATE_MAJOR, from .managers import (DocumentManager, DocumentPageTransformationManager, DocumentTypeManager, RecentDocumentManager) from .runtime import storage_backend -from .settings import (CACHE_PATH, CHECKSUM_FUNCTION, DISPLAY_SIZE, LANGUAGE, - UUID_FUNCTION, ZOOM_MAX_LEVEL, ZOOM_MIN_LEVEL) +from .settings import (CACHE_PATH, DISPLAY_SIZE, LANGUAGE, UUID_FUNCTION, + ZOOM_MAX_LEVEL, ZOOM_MIN_LEVEL) from .signals import post_version_upload, post_document_type_change HASH_FUNCTION = lambda x: hashlib.sha256(x).hexdigest() # document image cache name hash function @@ -388,7 +388,7 @@ class DocumentVersion(models.Model): """ if self.exists(): source = self.open() - self.checksum = unicode(CHECKSUM_FUNCTION(source.read())) + self.checksum = unicode(HASH_FUNCTION(source.read())) source.close() if save: self.save() diff --git a/mayan/apps/documents/settings.py b/mayan/apps/documents/settings.py index 964472c33c..9a3bd67345 100644 --- a/mayan/apps/documents/settings.py +++ b/mayan/apps/documents/settings.py @@ -1,6 +1,5 @@ """Configuration options for the documents app""" -import hashlib import os import uuid @@ -10,11 +9,6 @@ from django.utils.translation import ugettext_lazy as _ from smart_settings.api import register_settings -def default_checksum(x): - """hashlib.sha256(x).hexdigest()""" - return hashlib.sha256(x).hexdigest() - - def default_uuid(): """unicode(uuid.uuid4())""" return unicode(uuid.uuid4()) @@ -25,7 +19,6 @@ register_settings( module=u'documents.settings', settings=[ # Saving - {'name': u'CHECKSUM_FUNCTION', 'global_name': u'DOCUMENTS_CHECKSUM_FUNCTION', 'default': default_checksum}, {'name': u'UUID_FUNCTION', 'global_name': u'DOCUMENTS_UUID_FUNCTION', 'default': default_uuid}, # Storage {'name': u'STORAGE_BACKEND', 'global_name': u'DOCUMENTS_STORAGE_BACKEND', 'default': 'storage.backends.filebasedstorage.FileBasedStorage'},