Commit ed4f6c59 authored by Peter Kruczkiewicz's avatar Peter Kruczkiewicz

don't preview zip files as plain text

parent b66c79a3
Pipeline #6728 passed with stage
in 42 minutes and 16 seconds
...@@ -274,6 +274,7 @@ public class AnalysisController { ...@@ -274,6 +274,7 @@ public class AnalysisController {
Set<String> outputNames = analysis.getAnalysisOutputFileNames(); Set<String> outputNames = analysis.getAnalysisOutputFileNames();
return outputNames.stream() return outputNames.stream()
.map((outputName) -> getAnalysisOutputFileInfo(submission, analysis, outputName)) .map((outputName) -> getAnalysisOutputFileInfo(submission, analysis, outputName))
.filter(Objects::nonNull)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
...@@ -287,6 +288,7 @@ public class AnalysisController { ...@@ -287,6 +288,7 @@ public class AnalysisController {
*/ */
private AnalysisOutputFileInfo getAnalysisOutputFileInfo(AnalysisSubmission submission, Analysis analysis, private AnalysisOutputFileInfo getAnalysisOutputFileInfo(AnalysisSubmission submission, Analysis analysis,
String outputName) { String outputName) {
final ImmutableSet<String> BLACKLIST_FILE_EXT = ImmutableSet.of("zip");
// set of file extensions for indicating whether the first line of the file should be read // set of file extensions for indicating whether the first line of the file should be read
final ImmutableSet<String> FILE_EXT_READ_FIRST_LINE = ImmutableSet.of("tsv", "txt", "tabular", "csv", "tab"); final ImmutableSet<String> FILE_EXT_READ_FIRST_LINE = ImmutableSet.of("tsv", "txt", "tabular", "csv", "tab");
final AnalysisOutputFile aof = analysis.getAnalysisOutputFile(outputName); final AnalysisOutputFile aof = analysis.getAnalysisOutputFile(outputName);
...@@ -294,10 +296,16 @@ public class AnalysisController { ...@@ -294,10 +296,16 @@ public class AnalysisController {
final String aofFilename = aof.getFile() final String aofFilename = aof.getFile()
.getFileName() .getFileName()
.toString(); .toString();
final String fileExt = FileUtilities.getFileExt(aofFilename);
if (BLACKLIST_FILE_EXT.contains(fileExt))
{
return null;
}
final ToolExecution tool = aof.getCreatedByTool(); final ToolExecution tool = aof.getCreatedByTool();
final String toolName = tool.getToolName(); final String toolName = tool.getToolName();
final String toolVersion = tool.getToolVersion(); final String toolVersion = tool.getToolVersion();
final AnalysisOutputFileInfo info = new AnalysisOutputFileInfo(); final AnalysisOutputFileInfo info = new AnalysisOutputFileInfo();
info.setId(aofId); info.setId(aofId);
info.setAnalysisSubmissionId(submission.getId()); info.setAnalysisSubmissionId(submission.getId());
info.setAnalysisId(analysis.getId()); info.setAnalysisId(analysis.getId());
...@@ -308,7 +316,6 @@ public class AnalysisController { ...@@ -308,7 +316,6 @@ public class AnalysisController {
.length()); .length());
info.setToolName(toolName); info.setToolName(toolName);
info.setToolVersion(toolVersion); info.setToolVersion(toolVersion);
final String fileExt = FileUtilities.getFileExt(aofFilename);
info.setFileExt(fileExt); info.setFileExt(fileExt);
if (FILE_EXT_READ_FIRST_LINE.contains(fileExt)) { if (FILE_EXT_READ_FIRST_LINE.contains(fileExt)) {
addFirstLine(info, aof); addFirstLine(info, aof);
......
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