Skip to content

Commit 82ea2c5

Browse files
committed
deploy: Avoid cloning progress
Have the printer take ownership and return it. This is generally prep for making the writer more stateful which will make it easier to work with. Signed-off-by: Colin Walters <[email protected]>
1 parent adf18ea commit 82ea2c5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/src/deploy.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ async fn handle_layer_progress_print(
149149
bytes_total: u64,
150150
prog: ProgressWriter,
151151
quiet: bool,
152-
) {
152+
) -> ProgressWriter {
153153
let start = std::time::Instant::now();
154154
let mut total_read = 0u64;
155155
let bar = indicatif::MultiProgress::new();
@@ -299,6 +299,9 @@ async fn handle_layer_progress_print(
299299
.into(),
300300
})
301301
.await;
302+
303+
// Return the writer
304+
prog
302305
}
303306

304307
/// Wrapper for pulling a container image, wiring up status output.
@@ -333,7 +336,6 @@ pub(crate) async fn pull(
333336
let bytes_to_fetch: u64 = layers_to_fetch.iter().map(|(l, _)| l.layer.size()).sum();
334337
let bytes_total: u64 = prep.all_layers().map(|l| l.layer.size()).sum();
335338

336-
let prog_print = prog.clone();
337339
let digest = prep.manifest_digest.clone();
338340
let digest_imp = prep.manifest_digest.clone();
339341
let layer_progress = imp.request_progress();
@@ -347,13 +349,13 @@ pub(crate) async fn pull(
347349
layers_total,
348350
bytes_to_fetch,
349351
bytes_total,
350-
prog_print,
352+
prog,
351353
quiet,
352354
)
353355
.await
354356
});
355357
let import = imp.import(prep).await;
356-
let _ = printer.await;
358+
let prog = printer.await?;
357359
// Both the progress and the import are done, so import is done as well
358360
prog.send(Event::ProgressSteps {
359361
api_version: API_VERSION.into(),

0 commit comments

Comments
 (0)