From d4d405c840ce614aa9f338bba229298c69ca116f Mon Sep 17 00:00:00 2001 From: Dylan Jay Date: Sun, 1 Nov 2020 16:55:49 +0700 Subject: [PATCH 1/3] unicode error with hashing json content --- plugin.program.autowidget/resources/lib/common/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.program.autowidget/resources/lib/common/utils.py b/plugin.program.autowidget/resources/lib/common/utils.py index afee6028..4fd2e781 100644 --- a/plugin.program.autowidget/resources/lib/common/utils.py +++ b/plugin.program.autowidget/resources/lib/common/utils.py @@ -391,7 +391,7 @@ def cache_files(path): files_json = call_jsonrpc(json.dumps(params)) files = json.loads(files_json) write_json(cache_path, files) - expiry = cache_expiry(hash, add=hashlib.sha1(json.dumps(files_json)).hexdigest()) + expiry = cache_expiry(hash, add=hashlib.sha1(files_json.encode('utf8')).hexdigest()) log("Wrote cache (exp in {}s): {}".format(expiry-time.time(), hash), 'notice') return files From 383d536ab0fdb596689c132bbc83af603794a9c8 Mon Sep 17 00:00:00 2001 From: Dylan Jay Date: Sun, 1 Nov 2020 17:02:20 +0700 Subject: [PATCH 2/3] fix starting thread issue --- plugin.program.autowidget/resources/lib/refresh.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugin.program.autowidget/resources/lib/refresh.py b/plugin.program.autowidget/resources/lib/refresh.py index 8983289d..24fda655 100644 --- a/plugin.program.autowidget/resources/lib/refresh.py +++ b/plugin.program.autowidget/resources/lib/refresh.py @@ -255,11 +255,14 @@ def get_files_list(path, titles=None, widget_id=None): def queue_widget_update(widget_id): global _thread + new_thread = False if _thread is None or not _thread.is_alive(): _thread = Worker() _thread.daemon = True - _thread.queue.put(widget_id) - _thread.start() + new_thread = True + _thread.queue.put(widget_id) + if new_thread: + _thread.start() class Worker(threading.Thread): def __init__(self): From 71d3ac82164aef0e7f42c9e72b8dc1d726449194 Mon Sep 17 00:00:00 2001 From: Dylan Jay Date: Mon, 2 Nov 2020 00:03:03 +0700 Subject: [PATCH 3/3] fix incorrect merge --- plugin.program.autowidget/resources/lib/common/utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin.program.autowidget/resources/lib/common/utils.py b/plugin.program.autowidget/resources/lib/common/utils.py index 4fd2e781..c915fedd 100644 --- a/plugin.program.autowidget/resources/lib/common/utils.py +++ b/plugin.program.autowidget/resources/lib/common/utils.py @@ -378,7 +378,6 @@ def _get_json_version(): return (result['major'], result['minor'], result['patch']) def cache_files(path): - hash = hashlib.sha1(path).hexdigest() hash = hashlib.sha1(six.text_type(path)).hexdigest() cache_path = os.path.join(_addon_path, '{}.cache'.format(hash)) version = _get_json_version()