diff --git a/package_control/package_cleanup.py b/package_control/package_cleanup.py index ca6efb17..9ee1585e 100644 --- a/package_control/package_cleanup.py +++ b/package_control/package_cleanup.py @@ -105,6 +105,10 @@ def run(self): if self.manager.settings.get('auto_upgrade'): AutomaticUpgrader(self.manager).run() + # make sure to restore indexing state + # note: required after Package Control upgrade + self.resume_indexer() + if self.failed_cleanup: show_error( ''' diff --git a/package_control/package_disabler.py b/package_control/package_disabler.py index b683dc65..266e0322 100644 --- a/package_control/package_disabler.py +++ b/package_control/package_disabler.py @@ -544,25 +544,9 @@ def restore_settings(restore_id): settings = sublime.load_settings(preferences_filename()) save_settings = False - backup_json = os.path.join(pc_cache_dir(), 'backup.json') - try: # restore indexing settings - try: - with open(backup_json, 'r', encoding='utf-8') as fobj: - if json.load(fobj).get('index_files') is True: - settings.set('index_files', True) - save_settings = True - console_write('resuming indexer') - except FileNotFoundError: - pass - except Exception as e: - console_write('failed to resume indexer! %s', e) - - try: - os.remove(backup_json) - except OSError: - pass + save_settings = PackageDisabler.resume_indexer(False) # restore global theme all_missing_theme_packages = set() @@ -656,6 +640,32 @@ def restore_settings(restore_id): PackageDisabler.restore_id = 0 + @staticmethod + def resume_indexer(persist=True): + result = False + backup_json = os.path.join(pc_cache_dir(), 'backup.json') + try: + with open(backup_json, 'r', encoding='utf-8') as fobj: + if json.load(fobj).get('index_files') is True: + settings_file = preferences_filename() + settings = sublime.load_settings(settings_file) + settings.set('index_files', True) + if persist: + sublime.save_settings(settings_file) + console_write('resuming indexer') + result = True + except FileNotFoundError: + pass + except Exception as e: + console_write('failed to resume indexer! %s', e) + + try: + os.remove(backup_json) + except OSError: + pass + + return result + def resource_exists(path): """