1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-14 14:21:23 +00:00

Merge pull request #4961 from haiwen/cache-key-length

use sha1 encrypted str as cache key
This commit is contained in:
Daniel Pan
2021-08-06 12:21:10 +08:00
committed by GitHub
2 changed files with 8 additions and 4 deletions

View File

@@ -13,7 +13,7 @@ from seaserv import seafile_api
from seahub.base.templatetags.seahub_tags import email2nickname from seahub.base.templatetags.seahub_tags import email2nickname
from seahub.utils import get_file_type_and_ext, gen_file_get_url, \ from seahub.utils import get_file_type_and_ext, gen_file_get_url, \
get_site_scheme_and_netloc, normalize_cache_key get_site_scheme_and_netloc, encrypt_with_sha1
from seahub.utils.file_op import if_locked_by_online_office from seahub.utils.file_op import if_locked_by_online_office
from seahub.settings import ENABLE_WATERMARK from seahub.settings import ENABLE_WATERMARK
@@ -25,9 +25,8 @@ logger = logging.getLogger('onlyoffice')
def generate_onlyoffice_cache_key(repo_id, file_path): def generate_onlyoffice_cache_key(repo_id, file_path):
prefix = "ONLYOFFICE_"
value = "%s_%s" % (repo_id, file_path) return "ONLYOFFICE_{}_{}".format(repo_id, encrypt_with_sha1(file_path))
return normalize_cache_key(value, prefix)
def get_onlyoffice_dict(request, username, repo_id, file_path, file_id='', def get_onlyoffice_dict(request, username, repo_id, file_path, file_id='',

View File

@@ -1387,3 +1387,8 @@ def is_valid_org_id(org_id):
return True return True
else: else:
return False return False
def encrypt_with_sha1(origin_str):
return hashlib.sha1(origin_str.encode()).hexdigest()