summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorralph isenmann2020-12-01 14:21:17 +0100
committerralph isenmann2020-12-01 14:21:51 +0100
commit6b4aa287102a5de98ad03fd8965515c416d93044 (patch)
tree78569e69f432aff997cbea54505ba698138bab7a
parent[client] Refactoring (diff)
downloadtutor-module-6b4aa287102a5de98ad03fd8965515c416d93044.tar.gz
tutor-module-6b4aa287102a5de98ad03fd8965515c416d93044.tar.xz
tutor-module-6b4aa287102a5de98ad03fd8965515c416d93044.zip
[client] fix eol separator
A given dockerfile with windows eol style ("\r\n") will now be converted to unix eol ("\n")
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerDefinition.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerDefinition.java b/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerDefinition.java
index 46dba2e0..92ec6607 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerDefinition.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerDefinition.java
@@ -145,16 +145,22 @@ public class ContainerDefinition {
}
private String readContainerRecipe(File file) {
- byte[] rawFile = null;
+ String recipe = null;
try {
+
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
- rawFile = new byte[(int) file.length()];
+ byte[] rawFile = new byte[(int) file.length()];
bis.read(rawFile);
+ String rawRecipe = new String(rawFile, StandardCharsets.UTF_8);
+
+ // replace windows by unix EOL
+ recipe = rawRecipe.replaceAll("\\r\\n", "\n");
+
} catch (IOException e) {
LOGGER.error("Could not read Container Recipe", e);
}
- return new String(rawFile, StandardCharsets.UTF_8);
+ return recipe;
}
/**