private @Nullable FileInfo getShardFileInfo(File file) {
    FileInfo info = FileInfo.fromFile(file);
    if (info == null) {
      return null; // file with incorrect name/extension
    }
    File expectedDirectory = getSubdirectory(info.resourceId);
    boolean isCorrect = expectedDirectory.equals(file.getParentFile());
    return isCorrect ? info : null;
  }
Checks that the file is placed in the correct shard according to its filename (and hence the
represented key). If it's correct its FileInfo is returned.

@param file the file to check
@return the corresponding FileInfo object if shard is correct, null otherwise
imagepipeline-base/src/main/java/com/facebook/cache/disk/DefaultDiskStorage.java