Skip to content

Commit

Permalink
Merge pull request #13 from anxdpanic/dev
Browse files Browse the repository at this point in the history
2.6.0~alpha2
  • Loading branch information
anxdpanic authored Nov 18, 2019
2 parents 430df0d + eb32ad7 commit 49d8f79
Showing 2 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<addon id="script.common.plugin.cache" name="Common plugin cache" provider-name="anxdpanic, TheCollective" version="2.6.0~alpha1">
<addon id="script.common.plugin.cache" name="Common plugin cache" provider-name="anxdpanic, TheCollective" version="2.6.0~alpha2">
<requires>
<import addon="xbmc.python" version="2.24.0"/>
</requires>
40 changes: 34 additions & 6 deletions resources/lib/storage_server/StorageServer.py
Original file line number Diff line number Diff line change
@@ -33,6 +33,11 @@
except ImportError:
sqlite = None

try:
basestring
except NameError:
basestring = str

PY3 = sys.version_info[0] >= 3


@@ -522,14 +527,37 @@ def _generateKey(self, funct, *args):
if isinstance(params, dict):
for key in sorted(params.keys()):
if key not in ["new_results_function"]:
keyhash.update("'%s'='%s'" % (key, params[key]))
val = params[key]
if not isinstance(val, basestring):
val = str(val)
if PY3:
if isinstance(key, str):
key = key.encode('utf-8')
if isinstance(val, str):
val = val.encode('utf-8')
key_val_pair = b"'%s'='%s'" % (key, val)
else:
key_val_pair = "'%s'='%s'" % (key, val)
keyhash.update(key_val_pair)
elif isinstance(params, list):
keyhash.update(",".join(["%s" % el for el in params]))
if PY3:
hash_list = []
for el in params:
if not isinstance(el, basestring):
el = str(el)
if isinstance(el, str):
el = el.encode('utf-8')
hash_list.append(el)
keyhash.update(b",".join([b"%s" % el for el in hash_list]))
else:
keyhash.update(",".join(["%s" % el for el in params]))
else:
try:
keyhash.update(params)
except:
keyhash.update(str(params))
if not isinstance(params, basestring):
params = str(params)
if PY3:
if isinstance(params, str):
params = params.encode('utf-8')
keyhash.update(params)

name += "|" + keyhash.hexdigest() + "|"

0 comments on commit 49d8f79

Please sign in to comment.