in src/main/java/co/elastic/support/scrub/ScrubInputs.java [87:120]
public List<String> validateScrubInput(String path) {
if (StringUtils.isEmpty(path.trim())) {
return Collections.singletonList("Input archive, directory, or single file is required.");
}
File file = new File(path);
if (!file.exists()) {
return Collections.singletonList("Specified required file location could not be located or is a directory.");
}
int filePosition = path.lastIndexOf(SystemProperties.fileSeparator);
if (path.endsWith(".zip")) {
this.type = "zip";
scrubbedFileBaseName = path.substring(filePosition + 1).replace(".zip", "");
} else if (path.endsWith(".tar.gz")) {
this.type = "tar.gz";
scrubbedFileBaseName = path.substring(filePosition + 1).replace(".tar.gz", "");
} else if (path.endsWith(".tar")) {
this.type = "tar";
scrubbedFileBaseName = path.substring(filePosition + 1).replace(".tar", "");
} else if (file.isDirectory()) {
this.type = "dir";
isArchive = false;
scrubbedFileBaseName = path.substring(filePosition + 1);
} else {
this.type = "file";
isArchive = false;
scrubbedFileBaseName = path.substring(filePosition + 1, path.lastIndexOf("."));
}
return null;
}