Fix staging file filename hashing not working with unicode filenames

This commit is contained in:
Roberto Rosario
2012-03-03 01:12:56 -04:00
parent 631c41c4a2
commit 93a6aae9c2

View File

@@ -7,11 +7,12 @@ import hashlib
from django.core.files.base import File from django.core.files.base import File
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.utils.translation import ugettext from django.utils.translation import ugettext
from django.utils.encoding import smart_str
from documents.conf.settings import THUMBNAIL_SIZE from documents.conf.settings import THUMBNAIL_SIZE
from mimetype.api import get_icon_file_path, get_error_icon_file_path, \ from mimetype.api import (get_icon_file_path, get_error_icon_file_path,
get_mimetype get_mimetype)
from converter.api import convert, cache_cleanup from converter.api import convert, cache_cleanup
from converter.exceptions import UnknownFileFormat, UnkownConvertError from converter.exceptions import UnknownFileFormat, UnkownConvertError
@@ -102,7 +103,7 @@ class StagingFile(object):
self.source = source self.source = source
self.filepath = filepath self.filepath = filepath
self.filename = os.path.basename(filepath) self.filename = os.path.basename(filepath)
self._id = HASH_FUNCTION(filepath) self._id = HASH_FUNCTION(smart_str(filepath))
def __unicode__(self): def __unicode__(self):
return self.filename return self.filename