chiark / gitweb /
cli bundle progress: Report for files in the zip we're building
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 16 May 2022 00:31:30 +0000 (01:31 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 16 May 2022 02:09:35 +0000 (03:09 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
cli/usebundles.rs

index b390149739678ffdaf9fd4974c10b438d91118cf..f69af11a9bd0541c2f01e93075ab9a968622d5b8 100644 (file)
@@ -91,7 +91,8 @@ impl BundleForUpload {
     let zipfile = BufWriter::new(zipfile);
     let mut zipfile = zipfile::ZipWriter::new(zipfile);
 
-    for ent in entries {
+    let n_entries = entries.len();
+    for (entry_i, ent) in entries.into_iter().enumerate() {
       if ent.file_type().is_dir() { continue }
 
       let tail = {
@@ -104,6 +105,17 @@ impl BundleForUpload {
       let tail = tail.to_str()
         .ok_or_else(|| anyhow!("non-UTF-8 path in bundle {:?}", tail))?;
 
+      progress.report(&ProgressInfo {
+        phase: progress::Count {
+          desc: "building zip".into(),
+          value: progress::Value::Exact { i: 0, n: 1 },
+        },
+        item: progress::Count {
+          desc: tail.into(),
+          value: progress::Value::Exact { i: entry_i, n: n_entries },
+        }
+      });
+
       (||{
         let mut f = File::open(ent.path())
           .context("start to read")?;