private void updateData(MavenProgressIndicator progress) throws MavenIndexException { String newDataDirName; IndexData newData; newDataDirName = findAvailableDataDirName(); try { FileUtil.copyDir(getUpdateDir(), getDataContextDir(getDataDir(newDataDirName))); } catch (IOException e) { throw new MavenIndexException(e); } newData = openData(newDataDirName); try { doUpdateIndexData(newData, progress); newData.flush(); } catch (Throwable e) { newData.close(true); FileUtil.delete(getDataDir(newDataDirName)); if (e instanceof MavenServerIndexerException) throw new MavenIndexException(e); if (e instanceof IOException) throw new MavenIndexException(e); throw new RuntimeException(e); } synchronized (this) { IndexData oldData = myData; myData = newData; myDataDirName = newDataDirName; myUpdateTimestamp = System.currentTimeMillis(); oldData.close(true); File[] children = myDir.listFiles(); if (children != null) { for (File each : children) { if (each.getName().startsWith(DATA_DIR_PREFIX) && !each.getName().equals(newDataDirName)) { FileUtil.delete(each); } } } } }