if (trace) log.tracef("deleting metadata: %s", key);
final FileMetadata file = (FileMetadata) metadataCache.remove(key);
if (file != null) { //during optimization of index a same file could be deleted twice, so you could see a null here
final int bufferSize = file.getBufferSize();
for (int i = 0; i < file.getNumberOfChunks(); i++) {
ChunkCacheKey chunkKey = new ChunkCacheKey(indexName, filename, i, bufferSize);
if (trace) log.tracef("deleting chunk: %s", chunkKey);
chunksCache.withFlags(Flag.IGNORE_RETURN_VALUES).removeAsync(chunkKey);
}
}
// last operation, as being set as value==0 it prevents others from using it during the