summaryrefslogtreecommitdiff
path: root/buildstream/_cachekey.py
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2019-02-14 11:25:10 +0000
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2019-02-14 13:02:07 +0000
commitc2c10d68a5e3ed12d13adce2cb10feed789f8f8c (patch)
treed74d5d8a84a4f67dfe2aa7a8b22c91eb1141bddd /buildstream/_cachekey.py
parent9db7f489092a7d5ab14b223eb13fb8fce4829df1 (diff)
downloadbuildstream-danielsilverstone-ct/json-cache-key.tar.gz
Cache Keys: Update to use JSON rather than pickledanielsilverstone-ct/json-cache-key
This affects the cache key version (updated to 7) and introduces a dependency on `ujson` which is BSD licenced as of the version locked in `requirements.txt` Signed-off-by: Daniel Silverstone <daniel.silverstone@codethink.co.uk>
Diffstat (limited to 'buildstream/_cachekey.py')
-rw-r--r--buildstream/_cachekey.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/buildstream/_cachekey.py b/buildstream/_cachekey.py
index fe407e96f..953263aa9 100644
--- a/buildstream/_cachekey.py
+++ b/buildstream/_cachekey.py
@@ -19,7 +19,8 @@
import hashlib
-import pickle
+
+import ujson
from . import _yaml
@@ -38,5 +39,5 @@ from . import _yaml
#
def generate_key(value):
ordered = _yaml.node_sanitize(value)
- string = pickle.dumps(ordered)
- return hashlib.sha256(string).hexdigest()
+ ustring = ujson.dumps(ordered, sort_keys=True, escape_forward_slashes=False).encode('utf-8')
+ return hashlib.sha256(ustring).hexdigest()