From 1205fb400a7d3012a73b5c67c875dd53e6836382 Mon Sep 17 00:00:00 2001 From: Daniel Maljovec Date: Fri, 23 Oct 2020 17:54:38 -0600 Subject: [PATCH 1/2] fix: decode the post.uuid before comparing it with other uuids --- knowledge_repo/app/index.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/knowledge_repo/app/index.py b/knowledge_repo/app/index.py index 43da1afc4..fd05e4af9 100644 --- a/knowledge_repo/app/index.py +++ b/knowledge_repo/app/index.py @@ -153,9 +153,15 @@ def update_index(check_timeouts=True, force=False, reindex=False): posts = db_session.query(Post).all() for post in posts: + if isinstance(post.uuid, str) and post.uuid.starswith('\\x'): + decoded_post_uuid = bytes.fromhex(post.uuid.replace('\\x', '')) + elif isinstance(post.uuid, str): + decoded_post_uuid = bytes(post.uuid) + else: + decoded_post_uuid = post.uuid # If UUID has changed, check if we can find it elsewhere in the repository, and if so update index path - if post.uuid and ((post.path not in kr_dir) or (post.uuid != kr_dir[post.path].uuid)): + if post.uuid and ((post.path not in kr_dir) or (decoded_post_uuid != kr_dir[post.path].uuid)): if post.uuid in kr_uuids: logger.info('Updating location of post: {} -> {}'.format(post.path, kr_uuids[post.uuid].path)) post.path = kr_uuids[post.uuid].path @@ -172,7 +178,7 @@ def update_index(check_timeouts=True, force=False, reindex=False): kp = kr_dir.pop(post.path) # Update metadata of post if required - if reindex or (kp.revision > post.revision or not post.is_published or kp.uuid != post.uuid): + if reindex or (kp.revision > post.revision or not post.is_published or kp.uuid != decoded_post_uuid): if kp.is_valid(): logger.info('Recording update to post at: {}'.format(kp.path)) post.update_metadata_from_kp(kp) From 694288dab40f8b0463aec1014a2f0ff953ab44ef Mon Sep 17 00:00:00 2001 From: Daniel Maljovec Date: Sat, 24 Oct 2020 01:01:51 -0600 Subject: [PATCH 2/2] oops --- knowledge_repo/app/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knowledge_repo/app/index.py b/knowledge_repo/app/index.py index fd05e4af9..4eb218684 100644 --- a/knowledge_repo/app/index.py +++ b/knowledge_repo/app/index.py @@ -153,7 +153,7 @@ def update_index(check_timeouts=True, force=False, reindex=False): posts = db_session.query(Post).all() for post in posts: - if isinstance(post.uuid, str) and post.uuid.starswith('\\x'): + if isinstance(post.uuid, str) and post.uuid.startswith('\\x'): decoded_post_uuid = bytes.fromhex(post.uuid.replace('\\x', '')) elif isinstance(post.uuid, str): decoded_post_uuid = bytes(post.uuid)