Fix for system-wide QDN issues occuring when the metadata file has an empty chunks array.

It is quite likely that existing resources with both metadata and an empty chunks array will need to be republished, because this bug may have led to incorrect file deletions.
This commit is contained in:
CalDescent
2022-04-16 11:25:44 +01:00
parent 3b3368f950
commit c59869982b
2 changed files with 120 additions and 0 deletions

View File

@@ -478,6 +478,14 @@ public class ArbitraryDataFile {
// Read the metadata
List<byte[]> chunks = metadata.getChunks();
// If the chunks array is empty, then this resource has no chunks,
// so we must return false to avoid confusing the caller.
if (chunks.isEmpty()) {
return false;
}
// Otherwise, we need to check each chunk individually
for (byte[] chunkHash : chunks) {
ArbitraryDataFileChunk chunk = ArbitraryDataFileChunk.fromHash(chunkHash, this.signature);
if (!chunk.exists()) {