server/checkintegrity.py
changeset 10365 21461f80f348
parent 9797 4e640ab62f51
child 10589 7c23b7de2b8d
child 10625 684dbf6722ef
equal deleted inserted replaced
10364:8b35a898b334 10365:21461f80f348
    86     """reindex all entities in the repository"""
    86     """reindex all entities in the repository"""
    87     # deactivate modification_date hook since we don't want them
    87     # deactivate modification_date hook since we don't want them
    88     # to be updated due to the reindexation
    88     # to be updated due to the reindexation
    89     repo = cnx.repo
    89     repo = cnx.repo
    90     dbhelper = repo.system_source.dbhelper
    90     dbhelper = repo.system_source.dbhelper
    91     with cnx.ensure_cnx_set:
    91     cursor = cnx.cnxset.cu
    92         cursor = cnx.cnxset.cu
    92     if not dbhelper.has_fti_table(cursor):
    93         if not dbhelper.has_fti_table(cursor):
    93         print 'no text index table'
    94             print 'no text index table'
    94         dbhelper.init_fti(cursor)
    95             dbhelper.init_fti(cursor)
       
    96     repo.system_source.do_fti = True  # ensure full-text indexation is activated
    95     repo.system_source.do_fti = True  # ensure full-text indexation is activated
    97     if etypes is None:
    96     if etypes is None:
    98         print 'Reindexing entities'
    97         print 'Reindexing entities'
    99         etypes = set()
    98         etypes = set()
   100         for eschema in schema.entities():
    99         for eschema in schema.entities():
   398     if checks:
   397     if checks:
   399         eids_cache = {}
   398         eids_cache = {}
   400         with cnx.security_enabled(read=False, write=False): # ensure no read security
   399         with cnx.security_enabled(read=False, write=False): # ensure no read security
   401             for check in checks:
   400             for check in checks:
   402                 check_func = globals()['check_%s' % check]
   401                 check_func = globals()['check_%s' % check]
   403                 with cnx.ensure_cnx_set:
   402                 check_func(repo.schema, cnx, eids_cache, fix=fix)
   404                     check_func(repo.schema, cnx, eids_cache, fix=fix)
       
   405         if fix:
   403         if fix:
   406             cnx.commit()
   404             cnx.commit()
   407         else:
   405         else:
   408             print
   406             print
   409         if not fix:
   407         if not fix:
   410             print 'WARNING: Diagnostic run, nothing has been corrected'
   408             print 'WARNING: Diagnostic run, nothing has been corrected'
   411     if reindex:
   409     if reindex:
   412         cnx.rollback()
   410         cnx.rollback()
   413         with cnx.ensure_cnx_set:
   411         reindex_entities(repo.schema, cnx, withpb=withpb)
   414             reindex_entities(repo.schema, cnx, withpb=withpb)
       
   415         cnx.commit()
   412         cnx.commit()