From 18c64e493be558a3ec755c91873e0b1c2494515a Mon Sep 17 00:00:00 2001 From: Ruud Date: Tue, 21 Jan 2014 23:06:02 +0100 Subject: [PATCH] Don't cache post requests --- couchpotato/core/plugins/base.py | 16 ++++++++++------ couchpotato/core/providers/base.py | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/couchpotato/core/plugins/base.py b/couchpotato/core/plugins/base.py index f9280098..0625535e 100644 --- a/couchpotato/core/plugins/base.py +++ b/couchpotato/core/plugins/base.py @@ -244,11 +244,15 @@ class Plugin(object): log.error("Something went wrong when finishing the plugin function. Could not find the 'is_running' key") def getCache(self, cache_key, url = None, **kwargs): - cache_key_md5 = md5(cache_key) - cache = Env.get('cache').get(cache_key_md5) - if cache: - if not Env.get('dev'): log.debug('Getting cache %s', cache_key) - return cache + + use_cache = not len(kwargs.get('data', {})) > 0 and not kwargs.get('files') + + if use_cache: + cache_key_md5 = md5(cache_key) + cache = Env.get('cache').get(cache_key_md5) + if cache: + if not Env.get('dev'): log.debug('Getting cache %s', cache_key) + return cache if url: try: @@ -259,7 +263,7 @@ class Plugin(object): del kwargs['cache_timeout'] data = self.urlopen(url, **kwargs) - if data and cache_timeout > 0: + if data and cache_timeout > 0 and use_cache: self.setCache(cache_key, data, timeout = cache_timeout) return data except: diff --git a/couchpotato/core/providers/base.py b/couchpotato/core/providers/base.py index 1aceac40..7f755c3c 100644 --- a/couchpotato/core/providers/base.py +++ b/couchpotato/core/providers/base.py @@ -64,7 +64,7 @@ class Provider(Plugin): def getJsonData(self, url, decode_from = None, **kwargs): - cache_key = '%s%s' % (md5(url), md5('%s' % kwargs.get('params', {}))) + cache_key = md5(url) data = self.getCache(cache_key, url, **kwargs) if data: @@ -81,7 +81,7 @@ class Provider(Plugin): def getRSSData(self, url, item_path = 'channel/item', **kwargs): - cache_key = '%s%s' % (md5(url), md5('%s' % kwargs.get('params', {}))) + cache_key = md5(url) data = self.getCache(cache_key, url, **kwargs) if data and len(data) > 0: