From c9638ec3fa17d03490e5da16649da5efc8d83888 Mon Sep 17 00:00:00 2001 From: Ruud Date: Sun, 5 Oct 2014 18:47:30 +0200 Subject: [PATCH] Encode templ download destination --- couchpotato/core/plugins/file.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/couchpotato/core/plugins/file.py b/couchpotato/core/plugins/file.py index db6787d..56c5230 100644 --- a/couchpotato/core/plugins/file.py +++ b/couchpotato/core/plugins/file.py @@ -4,7 +4,7 @@ import traceback from couchpotato import get_db from couchpotato.api import addApiView from couchpotato.core.event import addEvent, fireEvent -from couchpotato.core.helpers.encoding import toUnicode +from couchpotato.core.helpers.encoding import toUnicode, ss, sp from couchpotato.core.helpers.variable import md5, getExt, isSubFolder from couchpotato.core.logger import CPLog from couchpotato.core.plugins.base import Plugin @@ -59,7 +59,7 @@ class FileManager(Plugin): log.error('Failed removing unused file: %s', traceback.format_exc()) def showCacheFile(self, route, **kwargs): - Env.get('app').add_handlers(".*$", [('%s%s' % (Env.get('api_base'), route), StaticFileHandler, {'path': Env.get('cache_dir')})]) + Env.get('app').add_handlers(".*$", [('%s%s' % (Env.get('api_base'), route), StaticFileHandler, {'path': toUnicode(Env.get('cache_dir'))})]) def download(self, url = '', dest = None, overwrite = False, urlopen_kwargs = None): if not urlopen_kwargs: urlopen_kwargs = {} @@ -68,7 +68,9 @@ class FileManager(Plugin): urlopen_kwargs['stream'] = True if not dest: # to Cache - dest = os.path.join(Env.get('cache_dir'), '%s.%s' % (md5(url), getExt(url))) + dest = os.path.join(Env.get('cache_dir'), ss('%s.%s' % (md5(url), getExt(url)))) + + dest = sp(dest) if not overwrite and os.path.isfile(dest): return dest