Skip to content

Commit ba4fc1f

Browse files
committed
Actually extract the files
1 parent 2ee4953 commit ba4fc1f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

tmc-langs-framework/src/main/java/fi/helsinki/cs/tmc/langs/io/zip/StudentFileAwareUnzipper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ public UnzipResult unzip(Path zip, Path target) throws IOException {
8383
}
8484
boolean shouldWrite;
8585
InputStream entryContent = zipFile.getInputStream(entry);
86+
byte[] entryData = IOUtils.toByteArray(entryContent);
8687
if (Files.exists(entryTargetPath)) {
8788
log.trace("Allowed to unzip, unzipping");
88-
byte[] entryData = IOUtils.toByteArray(entryContent);
89+
8990
if (fileContentEquals(target.toFile(), entryData)) {
9091
shouldWrite = false;
9192
result.unchangedFiles.add(entryTargetPath);
@@ -101,7 +102,7 @@ public UnzipResult unzip(Path zip, Path target) throws IOException {
101102
result.newFiles.add(entryTargetPath);
102103
}
103104
if (shouldWrite) {
104-
FileUtils.copyInputStreamToFile(entryContent, entryTargetPath.toFile());
105+
FileUtils.writeByteArrayToFile(entryTargetPath.toFile(), entryData);
105106
} else {
106107
log.trace("Not allowed to unzip, skipping file");
107108
result.skippedFiles.add(entryTargetPath);

tmc-langs-util/src/main/java/fi/helsinki/cs/tmc/langs/util/TaskExecutorImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import fi.helsinki.cs.tmc.langs.io.EverythingIsStudentFileStudentFilePolicy;
1111
import fi.helsinki.cs.tmc.langs.io.NothingIsStudentFileStudentFilePolicy;
1212
import fi.helsinki.cs.tmc.langs.io.zip.StudentFileAwareUnzipper;
13+
import fi.helsinki.cs.tmc.langs.io.zip.Unzipper;
1314

1415
import com.google.common.base.Optional;
1516

@@ -85,7 +86,7 @@ public void extractProject(
8586

8687
@Override
8788
public void extractAndRewriteEveryhing(Path compressedProject, Path targetLocation) throws IOException {
88-
StudentFileAwareUnzipper unzipper =
89+
Unzipper unzipper =
8990
new StudentFileAwareUnzipper(new NothingIsStudentFileStudentFilePolicy());
9091
unzipper.unzip(compressedProject, targetLocation);
9192
}

0 commit comments

Comments
 (0)