From 93a6aae9c2053eeb0ef5d97f40f3647d786b7586 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sat, 3 Mar 2012 01:12:56 -0400 Subject: [PATCH] Fix staging file filename hashing not working with unicode filenames --- apps/sources/staging.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/sources/staging.py b/apps/sources/staging.py index c6a92a2bcb..b62d78ced1 100644 --- a/apps/sources/staging.py +++ b/apps/sources/staging.py @@ -7,11 +7,12 @@ import hashlib from django.core.files.base import File from django.core.exceptions import ObjectDoesNotExist from django.utils.translation import ugettext +from django.utils.encoding import smart_str from documents.conf.settings import THUMBNAIL_SIZE -from mimetype.api import get_icon_file_path, get_error_icon_file_path, \ - get_mimetype +from mimetype.api import (get_icon_file_path, get_error_icon_file_path, + get_mimetype) from converter.api import convert, cache_cleanup from converter.exceptions import UnknownFileFormat, UnkownConvertError @@ -102,7 +103,7 @@ class StagingFile(object): self.source = source self.filepath = filepath self.filename = os.path.basename(filepath) - self._id = HASH_FUNCTION(filepath) + self._id = HASH_FUNCTION(smart_str(filepath)) def __unicode__(self): return self.filename