class CacheStorageFiles {

  DescriptorDigest getDigestFromFilename(Path layerFile) throws CacheCorruptedException {
    try {
      String hash = layerFile.getFileName().toString();
      return DescriptorDigest.fromHash(hash);

    } catch (DigestException | IndexOutOfBoundsException ex) {
      throw new CacheCorruptedException(
          cacheDirectory, "Layer file did not include valid hash: " + layerFile, ex);
    }
  }

    CacheStorageFiles(Path cacheDirectory);

}