From 7216f731854318ff96ab7a50c02c70558f377642 Mon Sep 17 00:00:00 2001 From: Ekaterina Chernova Date: Wed, 20 Jan 2016 18:39:35 +0300 Subject: [PATCH] Store cache files in a better way Add 'pickled' suffix instead of file extensions to not to mislead users. Files stored in cache as pickled objects, so they can be open as regular files. Change-Id: Ia6418696cf81de2bb1add175f27b6465fc91f6b9 Closes-Bug: #1520515 --- muranodashboard/common/cache.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/muranodashboard/common/cache.py b/muranodashboard/common/cache.py index a4385978d..10d18a6e8 100644 --- a/muranodashboard/common/cache.py +++ b/muranodashboard/common/cache.py @@ -66,6 +66,9 @@ def with_cache(*dst_parts): @functools.wraps(func) def __inner(request, app_id): path = os.path.join(_get_entry_path(app_id), *dst_parts) + # Remove file extensions since file content is pickled and + # could not be open as usual files + path = os.path.splitext(path)[0] + '-pickled' content = _load_from_file(path) if content is None: content = func(request, app_id)