From 711f1870cf2b6f9ba55ac9d657bc6eb62fac279f Mon Sep 17 00:00:00 2001 From: zhengxie Date: Wed, 31 May 2017 17:32:15 +0800 Subject: [PATCH] [onlyoffice] Fix doc key issue --- seahub/views/file.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/seahub/views/file.py b/seahub/views/file.py index 90238948e3..f8fd374ed9 100644 --- a/seahub/views/file.py +++ b/seahub/views/file.py @@ -17,6 +17,7 @@ import re import mimetypes import urlparse import datetime +import hashlib from django.core import signing from django.core.cache import cache @@ -28,6 +29,7 @@ from django.http import HttpResponse, Http404, HttpResponseRedirect, HttpRespons from django.shortcuts import render_to_response from django.template import RequestContext from django.utils.http import urlquote +from django.utils.encoding import force_bytes from django.utils.translation import ugettext as _ from django.views.decorators.http import require_POST from django.template.defaultfilters import filesizeformat @@ -455,7 +457,7 @@ def _file_view(request, repo_id, path): if ENABLE_ONLYOFFICE and not repo.encrypted and \ fileext in ONLYOFFICE_FILE_EXTENSION: - doc_key = obj_id + doc_key = hashlib.md5(force_bytes(repo_id + path + obj_id)).hexdigest()[:20] if fileext in ('xls', 'xlsx', 'ods', 'fods', 'csv'): document_type = 'spreadsheet' elif fileext in ('pptx', 'ppt', 'odp', 'fodp', 'ppsx', 'pps'):