private boolean isExpectedFile(File file) {
      FileInfo info = getShardFileInfo(file);
      if (info == null) {
        return false;
      }
      if (info.type == FileType.TEMP) {
        return isRecentFile(file);
      }
      Preconditions.checkState(info.type == FileType.CONTENT);
      return true;
    }
This implements a {@link FileTreeVisitor} to iterate over all the files in mDirectory and
delete any unexpected file or directory. It also gets rid of any empty directory in the shard.
As a shortcut it checks that things are inside (current) mVersionDirectory. If it's not then
it's directly deleted. If it's inside then it checks if it's a recognized file and if it's in
the correct shard according to its name (checkShard method). If it's unexpected file is
deleted.
imagepipeline-base/src/main/java/com/facebook/cache/disk/DefaultDiskStorage.java