From eea2bbc821f94be48e773c233cbd439215520027 Mon Sep 17 00:00:00 2001 From: David Erni Date: Thu, 13 Jun 2019 16:03:51 +0200 Subject: [PATCH] TMP: XXX --- ftw/catalogdoctor/surgery.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ftw/catalogdoctor/surgery.py b/ftw/catalogdoctor/surgery.py index 69fc011..6f56f12 100644 --- a/ftw/catalogdoctor/surgery.py +++ b/ftw/catalogdoctor/surgery.py @@ -269,6 +269,29 @@ def perform(self): self.change_catalog_length(-1) +class ReindexMissingUUID(Surgery): + """Reindex an uuid which is partially missing from the UID index. + + Simply reindexing the object restores the consistent catalog state. + """ + def perform(self): + if len(self.unhealthy_rid.paths) != 1: + raise CantPerformSurgery( + "Expected exactly one affected path, got: {}" + .format(", ".join(self.unhealthy_rid.paths))) + + path = list(self.unhealthy_rid.paths)[0] + + portal = api.portal.get() + obj = portal.unrestrictedTraverse(path, None) + if obj is None: + raise CantPerformSurgery( + "Missing object at {}".format(path)) + + obj.reindexObject() + self.surgery_log.append("Reindexed object in catalog.") + + class CatalogDoctor(object): """Performs surgery for an unhealthy_rid, if possible. @@ -291,6 +314,10 @@ class CatalogDoctor(object): 'in_uuid_unindex_not_in_catalog', 'in_uuid_unindex_not_in_uuid_index', ): RemoveOrphanedRid, + ( + 'in_catalog_not_in_uuid_index', + 'in_uuid_unindex_not_in_uuid_index', + ): ReindexMissingUUID, } def __init__(self, catalog, unhealthy_rid):