Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit 4b246aa

Browse files
author
juvester
committed
Do not download completed exercises on Update
Skip those that were completed on another computer/folder
1 parent 811f1d8 commit 4b246aa

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/main/java/fi/helsinki/cs/tmc/cli/command/UpdateCommand.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@ private void printExercises(List<Exercise> exercises, String message) {
8181
if (!exercises.isEmpty()) {
8282
io.println(message);
8383
for (Exercise exercise : exercises) {
84-
io.println(" " + exercise.getName());
84+
if (exercise.isCompleted()) {
85+
// already released and completed on another computer/folder
86+
io.println(" " + exercise.getName() + " (already completed)");
87+
} else {
88+
io.println(" " + exercise.getName());
89+
}
8590
}
8691
}
8792
}

src/main/java/fi/helsinki/cs/tmc/cli/tmcstuff/ExerciseUpdater.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import java.nio.file.Path;
1313
import java.util.ArrayList;
14+
import java.util.Iterator;
1415
import java.util.List;
1516

1617
public class ExerciseUpdater {
@@ -88,7 +89,14 @@ public boolean updatesAvailable() {
8889
}
8990

9091
public List<Exercise> downloadUpdates(TmcCliProgressObserver progobs) {
91-
return TmcUtil.downloadExercises(core, getNewAndUpdatedExercises(), progobs);
92+
List<Exercise> newAndUpdated = getNewAndUpdatedExercises();
93+
for (Iterator<Exercise> iterator = newAndUpdated.iterator(); iterator.hasNext();) {
94+
Exercise next = iterator.next();
95+
if (next.isCompleted()) {
96+
iterator.remove();
97+
}
98+
}
99+
return TmcUtil.downloadExercises(core, newAndUpdated, progobs);
92100
}
93101

94102
public boolean updateCourseJson(CourseInfo info, Path configFile) {

0 commit comments

Comments
 (0)