Skip to content

Commit

Permalink
TMP: XXX
Browse files Browse the repository at this point in the history
  • Loading branch information
deiferni committed Jun 13, 2019
1 parent 9e6ac18 commit eea2bbc
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions ftw/catalogdoctor/surgery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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):
Expand Down

0 comments on commit eea2bbc

Please sign in to comment.