public void ensureStoragesVersionsAreConsistent(int currentImplVersion) throws IOException {
    LOG.info("VFS: impl (expected) version=" + currentImplVersion +
             ", " + recordsStorage.recordsCount() + " file records" +
             ", " + contentsStorage.getRecordsCount() + " content blobs");


    if (currentImplVersion == 0) {
      throw new IllegalArgumentException("currentImplVersion(=" + currentImplVersion + ") must be != 0");
    }
    //Versions of different storages should be either all set, and all == currentImplementationVersion,
    // or none set at all (& storages are all fresh & empty) -- everything but that is a version mismatch
    // and a trigger for VFS rebuild:

    int commonVersion = commonVersionIfExists(recordsStorage, attributesStorage, contentsStorage);

    if (commonVersion != currentImplVersion) {
      //If (commonVersion=0) AND (all storages are empty)
      //   => storages were just created
      //   => we should stamp them with current implVersion and go ahead.
      boolean storagesAreEmpty = recordsStorage.recordsCount() == 0
                                 && contentsStorage.isEmpty()
                                 && attributesStorage.isEmpty();
      if (commonVersion == 0 && storagesAreEmpty) {
        //all storages are fresh new => assign their versions to the current one:
        setCurrentVersion(recordsStorage, attributesStorage, contentsStorage, currentImplVersion);
        return;
      }

      //Otherwise: (not all storages are empty OR commonVersion != 0)
      //   => it is a version mismatch
      //   => we should rebuild VFS storages from 0.


      //if commonVersion > 0  => current VFS data _has_ a consistent version, but != implVersion
      //                      => IMPL_VERSION_MISMATCH
      //if commonVersion = -1 => different VFS storages have different, inconsistent versions
      //                      => UNRECOGNIZED (I guess it is a rare case, most probably happens if users play hard
      //                         with their IDE installations -- most likely they are our QAs -- or it is Nightly,
      //                         and we're changing VFS file layout... -- anyway, those are cases that are not worth
      //                         dedicated statistics/enum constant)
      VFSInitException.ErrorCategory rebuildCause = commonVersion > 0 ? IMPL_VERSION_MISMATCH : UNRECOGNIZED;
      throw new VFSInitException(
        rebuildCause,
        "VFS storages detected version(=" + commonVersion + ") != current impl version(=" + currentImplVersion + ") -> VFS needs rebuild"
      );
    }
  }
public void ensureStoragesVersionsAreConsistent(int currentImplVersion)