comparison src/memory/cache.py @ 2166:1b3fbb76984b

core (memory/cache): escape profile when creating cache dir
author Goffi <goffi@goffi.org>
date Sun, 26 Feb 2017 18:20:27 +0100
parents 766dbbec56f2
children 8b37a62336c3
comparison
equal deleted inserted replaced
2165:a0fbb2b11fd0 2166:1b3fbb76984b
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 from sat.core.log import getLogger 20 from sat.core.log import getLogger
21 log = getLogger(__name__) 21 log = getLogger(__name__)
22 from sat.tools.common import regex
22 from sat.core import exceptions 23 from sat.core import exceptions
23 from sat.core.constants import Const as C 24 from sat.core.constants import Const as C
24 import cPickle as pickle 25 import cPickle as pickle
25 import mimetypes 26 import mimetypes
26 import os.path 27 import os.path
34 host = host 35 host = host
35 self.profile = profile 36 self.profile = profile
36 self.cache_dir = os.path.join( 37 self.cache_dir = os.path.join(
37 host.memory.getConfig('', 'local_dir'), 38 host.memory.getConfig('', 'local_dir'),
38 C.CACHE_DIR, 39 C.CACHE_DIR,
39 profile or '') 40 regex.pathEscape(profile or ''))
40 if not os.path.exists(self.cache_dir): 41 if not os.path.exists(self.cache_dir):
41 os.makedirs(self.cache_dir) 42 os.makedirs(self.cache_dir)
42 43
43 def getPath(self, filename): 44 def getPath(self, filename):
44 """return cached file URL 45 """return cached file URL