Skip to content

Commit 573dbaf

Browse files
committed
Fix deletion policy
1 parent d888fee commit 573dbaf

File tree

12 files changed

+16
-17
lines changed

12 files changed

+16
-17
lines changed

build-tools/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>fi.helsinki.cs.tmc</groupId>
44
<artifactId>build-tools</artifactId>
5-
<version>0.7.4-SNAPSHOT</version>
5+
<version>0.7.5-SNAPSHOT</version>
66
<name>build-tools</name>
77

88
<!-- Deploy to maven.testmycode.net/nexus -->

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>fi.helsinki.cs.tmc</groupId>
55
<artifactId>tmc-langs</artifactId>
6-
<version>0.7.4-SNAPSHOT</version>
6+
<version>0.7.5-SNAPSHOT</version>
77
<packaging>pom</packaging>
88
<name>tmc-langs</name>
99
<url>http://testmycode.net</url>

tmc-langs-cli/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<artifactId>tmc-langs</artifactId>
66
<groupId>fi.helsinki.cs.tmc</groupId>
7-
<version>0.7.4-SNAPSHOT</version>
7+
<version>0.7.5-SNAPSHOT</version>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>
1010

tmc-langs-framework/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>fi.helsinki.cs.tmc</groupId>
66
<artifactId>tmc-langs</artifactId>
7-
<version>0.7.4-SNAPSHOT</version>
7+
<version>0.7.5-SNAPSHOT</version>
88
<relativePath>../</relativePath>
99
</parent>
1010
<properties>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,6 @@ private void loadExtraStudentFileList() {
102102

103103
@Override
104104
public boolean mayDelete(Path file, Path projectRoot) {
105-
return false;
105+
return !isStudentFile(file, projectRoot);
106106
}
107107
}

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.nio.file.Path;
2323
import java.util.Enumeration;
2424
import java.util.Set;
25-
import java.util.zip.ZipEntry;
2625

2726
public final class StudentFileAwareUnzipper implements Unzipper {
2827

@@ -121,23 +120,23 @@ public UnzipResult unzip(Path zip, Path target) throws IOException {
121120
}
122121

123122
log.debug("Done unzipping");
124-
deleteFilesNotInZip(target, target, result, pathsInZip);
123+
deleteFilesNotInZip(target, result, pathsInZip);
125124
return null;
126125
}
127126

128127
// TODO: validate
129128
private void deleteFilesNotInZip(
130-
Path projectDir, Path curDir, UnzipResult result, Set<Path> pathsInZip)
129+
Path projectDir, UnzipResult result, Set<Path> pathsInZip)
131130
throws IOException {
132131

133-
for (File file : curDir.toFile().listFiles()) {
132+
for (File file : projectDir.toFile().listFiles()) {
134133
Path filePath = file.toPath();
135134
if (file.isDirectory()) {
136-
deleteFilesNotInZip(projectDir, file.toPath(), result, pathsInZip);
135+
deleteFilesNotInZip(file.toPath(), result, pathsInZip);
137136
}
138137

139138
if (!pathsInZip.contains(filePath)) {
140-
if (mayDelete(filePath, null)) {
139+
if (mayDelete(filePath, projectDir)) {
141140
if (file.isDirectory() && file.listFiles().length > 0) {
142141
// Won't delete directories if they still have contents
143142
result.skippedDeletingFiles.add(filePath);

tmc-langs-framework/src/test/java/fi/helsinki/cs/tmc/langs/io/zip/StudentFileAwareUnzipperTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public void testDeletion() throws Exception {
134134
Path bad = TestUtils.getPath(StudentFileAwareUnzipperTest.class, "zip")
135135
.resolve("bad-test-class-name.zip");
136136
Path fixed = TestUtils.getPath(StudentFileAwareUnzipperTest.class, "zip")
137-
.resolve("fixed-test-class-name.zip");
137+
.resolve("fixed-test-class-name.zip");
138138

139139
unzipper.unzip(bad, tmpDir);
140140

tmc-langs-java/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>fi.helsinki.cs.tmc</groupId>
66
<artifactId>tmc-langs</artifactId>
7-
<version>0.7.4-SNAPSHOT</version>
7+
<version>0.7.5-SNAPSHOT</version>
88
</parent>
99

1010
<properties>

tmc-langs-make/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>fi.helsinki.cs.tmc</groupId>
66
<artifactId>tmc-langs</artifactId>
7-
<version>0.7.4-SNAPSHOT</version>
7+
<version>0.7.5-SNAPSHOT</version>
88
</parent>
99

1010
<properties>

tmc-langs-notests/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>fi.helsinki.cs.tmc</groupId>
66
<artifactId>tmc-langs</artifactId>
7-
<version>0.7.4-SNAPSHOT</version>
7+
<version>0.7.5-SNAPSHOT</version>
88
</parent>
99

1010
<properties>

0 commit comments

Comments
 (0)