This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit 2b223ca8 authored by Daniel Crazzolara's avatar Daniel Crazzolara
Browse files

Renamed tmp directory to tmp-import to avoid exceptions

parent efb7586f
2 merge requests!188Merging Peer Reviewing et. al to Master,!164211 peer reviewing functionality
......@@ -46,7 +46,7 @@ public class ExerciseService {
/**
* Retrieve a zipped Artemis Exercise from a given URL
* and store it in 'tmp' directory
* and store it in 'tmp-import' directory
* @param exerciseUrl the url of the exposed exercise
* @throws ArtemisImportError
*/
......@@ -75,7 +75,7 @@ public class ExerciseService {
* - Copy, commit and push files to the new repository
*
* @param exerciseInfo of the exercise to import
* @param exerciseToken of the stored exercise (in '/tmp' directory) to import
* @param exerciseToken of the stored exercise (in '/tmp-import' directory) to import
*/
public void importExercise(ArtemisExerciseInfo exerciseInfo, String exerciseToken, Integer gitlabGroupId) throws GitLabApiException, GitAPIException, IOException {
applyExerciseInfoChanges(exerciseInfo, exerciseToken);
......@@ -87,9 +87,9 @@ public class ExerciseService {
if (repo == null) {
throw new JGitInternalException("Repository couldn't be cloned.");
}
gitlabService.commitAndPushToRepo(repo, new File("tmp", exerciseToken));
gitlabService.commitAndPushToRepo(repo, new File("tmp-import", exerciseToken));
FileUtils.deleteDirectory(new File("tmp", exerciseToken));
FileUtils.deleteDirectory(new File("tmp-import", exerciseToken));
}
/**
......@@ -101,8 +101,8 @@ public class ExerciseService {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING)
.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS);
ArtemisExerciseInfo artemisExerciseInfo = mapper.readValue(new File("tmp/" + exerciseToken, "artemis.yaml"), ArtemisExerciseInfo.class);
ExerciseInfo exerciseInfo = mapper.readValue(new File("tmp/" + exerciseToken, "metadata.yaml"), ExerciseInfo.class);
ArtemisExerciseInfo artemisExerciseInfo = mapper.readValue(new File("tmp-import/" + exerciseToken, "artemis.yaml"), ArtemisExerciseInfo.class);
ExerciseInfo exerciseInfo = mapper.readValue(new File("tmp-import/" + exerciseToken, "metadata.yaml"), ExerciseInfo.class);
artemisExerciseInfo.appendExerciseInfo(exerciseInfo);
return artemisExerciseInfo;
}
......@@ -113,12 +113,12 @@ public class ExerciseService {
* @param subDir name of the tmp-subdirectory
*/
private void storeZipInTmp(ZipInputStream zipInputStream, String subDir) throws IOException {
if (!new File("tmp").exists()) {
if (!new File("tmp").mkdir()) {
throw new IOException("Could not create missing '/tmp' directory");
if (!new File("tmp-import").exists()) {
if (!new File("tmp-import").mkdir()) {
throw new IOException("Could not create missing '/tmp-import' directory");
}
}
File tmpDir = new File("tmp", subDir);
File tmpDir = new File("tmp-import", subDir);
if (!tmpDir.mkdir()) {
throw new IOException("Temporary exercise directory could not be created");
}
......@@ -165,7 +165,7 @@ public class ExerciseService {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory()
.enable(YAMLGenerator.Feature.INDENT_ARRAYS)
.disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER));
mapper.writeValue(new File("tmp/" + exerciseToken, "metadata.yaml"), exerciseInfo.getExerciseInfoOnly());
mapper.writeValue(new File("tmp-import/" + exerciseToken, "metadata.yaml"), exerciseInfo.getExerciseInfoOnly());
}
/**
......
......@@ -238,7 +238,7 @@ public class GitlabService {
*/
public Repository checkoutRepo(String repoUrl) throws IOException {
String repoDirName = repoUrl.split("/")[repoUrl.split("/").length - 1];
File dst = new File("tmp", repoDirName);
File dst = new File("tmp-import", repoDirName);
if (dst.exists()) {
log.debug("Temporary directory '{}' already exists, removing it.", dst.getPath());
FileUtils.deleteDirectory(dst);
......
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