Commit ae022e1e authored by Rolf Krahl's avatar Rolf Krahl

Throw an error if a duplicate entry is encountered in the archive file.

parent 62184f81
......@@ -4,8 +4,10 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
......@@ -92,14 +94,19 @@ public class DsRestorer implements Runnable {
+ " files of total size " + size);
ZipInputStream zis = new ZipInputStream(Files.newInputStream(datasetCachePath));
ZipEntry ze = zis.getNextEntry();
Set<String> seen = new HashSet<>();
while (ze != null) {
String dfName = zipMapper.getFileName(ze.getName());
if (seen.contains(dfName)) {
throw new RuntimeException("Corrupt archive for " + dsInfo + ": duplicate entry " + dfName);
}
String location = nameToLocalMap.get(dfName);
if (location == null) {
throw new RuntimeException("Corrupt archive for " + dsInfo + ": spurious entry " + dfName);
}
mainStorageInterface.put(zis, location);
ze = zis.getNextEntry();
seen.add(dfName);
}
zis.close();
Files.delete(datasetCachePath);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment