void (@NotNull PersistentFSLoader loader) { List<VFSInitException> contentStoragesProblems = loader.problemsDuringLoad( CONTENT_STORAGES_NOT_MATCH, CONTENT_STORAGES_INCOMPLETE ); if (contentStoragesProblems.isEmpty()) { return; } try { LOG.info(contentStoragesProblems.size() + " ContentStorage-related issue(s) -> trying to fix"); PersistentFSRecordsStorage records = loader.recordsStorage(); try { checkContentStorage(loader); //If contentStorage is OK -> try to re-create contentHashesEnumerator, and re-fill it by contentsStorage data: tryRebuildHashesStorageByContentStorage(loader); //MAYBE IDEA-334517: re-check contentHashStorage: is it really 'fixed'? loader.problemsWereRecovered(contentStoragesProblems); LOG.info("ContentHashesEnumerator was successfully rebuild, ContentStorage was verified along the way"); } catch (Throwable ex) { LOG.warn("ContentStorage check is failed: " + ex.getMessage()); //Seems like the ContentStorage itself is broken -> clean both Content & ContentHashes storages, // and invalidate all the contentId references from fs-records: RefCountingContentStorage contentStorage = loader.contentsStorage(); contentStorage.closeAndClean(); ContentHashEnumerator contentHashEnumerator = loader.contentHashesEnumerator(); contentHashEnumerator.closeAndClean(); RefCountingContentStorage emptyContentStorage = loader.createContentStorage(loader.contentsFile); ContentHashEnumerator emptyHashesEnumerator = PersistentFSLoader.createContentHashStorage(loader.contentsHashesFile); loader.setContentsStorage(emptyContentStorage); loader.setContentHashesEnumerator(emptyHashesEnumerator); cleanAllContentIds(records); // FIXME MAYBE VfsLog recovery related: we don't place a special event in VfsLog about content storage being cleared. // Clearing all references to old contents from records should suffice. //inform others (LocalHistory) that old contentIds are no longer valid: loader.contentIdsInvalidated(true); loader.problemsWereRecovered(contentStoragesProblems); LOG.warn("ContentStorage is found broken -> fixed by invalidating all the content refs (LocalHistory is lost)"); } } catch (Throwable t) { loader.problemsRecoveryFailed( contentStoragesProblems, CONTENT_STORAGES_INCOMPLETE, "Content enumerator recovery fails", t ); } }