Java Code Examples for com.intellij.util.io.IOUtil#deleteAllFilesStartingWith()

The following examples show how to use com.intellij.util.io.IOUtil#deleteAllFilesStartingWith() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestStateStorage.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void thingsWentWrongLetsReinitialize(IOException e, String message) {
  try {
    if (myMap != null) {
      try {
        myMap.close();
      }
      catch (IOException ignore) {
      }
      IOUtil.deleteAllFilesStartingWith(myFile);
    }
    myMap = initializeMap();
    LOG.error(message, e);
  }
  catch (IOException e1) {
    LOG.error("Cannot repair", e1);
    myMap = null;
  }
}
 
Example 2
Source File: SerializationManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void repairNameStorage() {
  if (myNameStorageCrashed.getAndSet(false)) {
    try {
      LOG.info("Name storage is repaired");
      if (myNameStorage != null) {
        myNameStorage.close();
      }

      StubSerializationHelper prevHelper = myStubSerializationHelper;
      if (myUnmodifiable) {
        LOG.error("Data provided by unmodifiable serialization manager can be invalid after repair");
      }

      IOUtil.deleteAllFilesStartingWith(myFile);
      myNameStorage = new PersistentStringEnumerator(myFile, true);
      myStubSerializationHelper = new StubSerializationHelper(myNameStorage, myUnmodifiable, this);
      myStubSerializationHelper.copyFrom(prevHelper);
    }
    catch (IOException e) {
      LOG.info(e);
      nameStorageCrashed();
    }
  }
}
 
Example 3
Source File: ContentHashesSupport.java    From consulo with Apache License 2.0 6 votes vote down vote up
static void initContentHashesEnumerator() throws IOException {
  if (ourHashesWithFileType != null) return;
  synchronized (ContentHashesSupport.class) {
    if (ourHashesWithFileType != null) return;
    final File hashEnumeratorFile = new File(IndexInfrastructure.getPersistentIndexRoot(), "hashesWithFileType");
    try {
      ContentHashesUtil.HashEnumerator hashEnumerator = new ContentHashesUtil.HashEnumerator(hashEnumeratorFile, null);
      FlushingDaemon.everyFiveSeconds(ContentHashesSupport::flushContentHashes);
      ShutDownTracker.getInstance().registerShutdownTask(ContentHashesSupport::flushContentHashes);
      ourHashesWithFileType = hashEnumerator;
    }
    catch (IOException ex) {
      IOUtil.deleteAllFilesStartingWith(hashEnumeratorFile);
      throw ex;
    }
  }
}