Skip to content

Commit c111424

Browse files
committed
progress reporting for download exercise
1 parent 381e013 commit c111424

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tmc-langs-core/src/tmc_core.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,22 @@ impl TmcCore {
215215
/// ]);
216216
/// ```
217217
pub fn download_or_update_exercises(&self, exercises: Vec<(usize, &Path)>) -> Result<()> {
218+
let step = 1.0 / (2 * exercises.len()) as f64;
219+
220+
let mut progress = 0.0;
218221
for (exercise_id, target) in exercises {
222+
// TODO: do in memory without zip_file?
219223
let zip_file = NamedTempFile::new().map_err(CoreError::TempFile)?;
224+
225+
self.report_progress("Downloading exercise...", progress);
220226
self.download_exercise(exercise_id, zip_file.path())?;
227+
progress += step;
228+
229+
self.report_progress("Extracting exercise...", progress);
221230
task_executor::extract_project(zip_file.path(), target)?;
231+
progress += step;
222232
}
233+
self.report_complete("Finished downloading and extracting exercises.");
223234
Ok(())
224235
}
225236

0 commit comments

Comments
 (0)