Skip to content

Commit 505e567

Browse files
authored
Merge pull request #137 from rage/dont-fail-on-dl-fail
do not fail download-or-update if some downloads fail
2 parents edceabb + 95444dd commit 505e567

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

tmc-langs-cli/src/lib.rs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ fn run_core(
733733
.collect::<Result<Vec<_>>>()?;
734734

735735
let projects_dir = tmc_langs::get_projects_dir(client_name)?;
736-
match tmc_langs::download_or_update_course_exercises(
736+
let data = match tmc_langs::download_or_update_course_exercises(
737737
&client,
738738
&projects_dir,
739739
&exercise_ids,
@@ -742,29 +742,26 @@ fn run_core(
742742
DownloadResult::Success {
743743
downloaded,
744744
skipped,
745-
} => {
746-
let data = DownloadOrUpdateCourseExercisesResult {
747-
downloaded,
748-
skipped,
749-
};
750-
let output = Output::finished_with_data(
751-
"downloaded or updated exercises",
752-
Data::ExerciseDownload(data),
753-
);
754-
print_output(&output, pretty)?
755-
}
745+
} => DownloadOrUpdateCourseExercisesResult {
746+
downloaded,
747+
skipped,
748+
failed: None,
749+
},
756750
DownloadResult::Failure {
757751
downloaded,
758752
skipped,
759753
failed,
760-
} => {
761-
anyhow::bail!(DownloadsFailedError {
762-
downloaded,
763-
skipped,
764-
failed,
765-
})
766-
}
767-
}
754+
} => DownloadOrUpdateCourseExercisesResult {
755+
downloaded,
756+
skipped,
757+
failed: Some(failed),
758+
},
759+
};
760+
let output = Output::finished_with_data(
761+
"downloaded or updated exercises",
762+
Data::ExerciseDownload(data),
763+
);
764+
print_output(&output, pretty)?
768765
}
769766
("get-course-data", Some(matches)) => {
770767
let course_id = matches.value_of("course-id").unwrap();

tmc-langs-cli/src/output.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ mod test {
213213
exercise_slug: "some skipped exercise".to_string(),
214214
path: PathBuf::from("third path"),
215215
}],
216+
failed: None,
216217
},
217218
)),
218219
});

tmc-langs/src/data.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,6 @@ pub struct CombinedCourseData {
196196
pub struct DownloadOrUpdateCourseExercisesResult {
197197
pub downloaded: Vec<ExerciseDownload>,
198198
pub skipped: Vec<ExerciseDownload>,
199+
#[serde(skip_serializing_if = "Option::is_none")]
200+
pub failed: Option<Vec<(ExerciseDownload, Vec<String>)>>,
199201
}

tmc-langs/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ pub fn update_exercises(
551551
Ok(DownloadOrUpdateCourseExercisesResult {
552552
downloaded: exercises_to_update,
553553
skipped: vec![],
554+
failed: None,
554555
})
555556
}
556557

0 commit comments

Comments
 (0)