Issue #56, remove configurability of the checksum algorithm
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
@@ -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**
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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'},
|
||||
|
||||
Reference in New Issue
Block a user