Skip to content

Commit 48124b0

Browse files
deploy: fix progress bar math for containers-storage transport (#2067)
When pulling from containers-storage, layers are stored uncompressed but the progress bar total was set from the manifest descriptor size (compressed). This caused the display to show transferred exceeding total, e.g. '2.66 GiB/1.14 GiB'. Update the byte progress bar length from LayerProgress.total on each update, which reflects the actual blob size for the transport. Also use the bar's actual length for completion accounting so that total_read and subtask bytes are consistent. This matches how ostree-ext's CLI handles the same progress (cli.rs). For registry pulls, LayerProgress.total equals the manifest descriptor size, so this is a no-op in that case. Closes: #2001 Signed-off-by: Andrew Dunn <andrew@dunn.dev>
1 parent 5dd036d commit 48124b0

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

crates/lib/src/deploy.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,15 @@ async fn handle_layer_progress_print(mut config: LayerProgressConfig) -> Progres
234234
bytes_total: layer_size,
235235
};
236236
} else {
237-
byte_bar.set_position(layer_size);
237+
// Use the bar's length (actual blob size) rather than
238+
// the manifest descriptor size for completion accounting.
239+
let actual_size = byte_bar.length().unwrap_or(layer_size);
240+
byte_bar.set_position(actual_size);
238241
layers_bar.inc(1);
239-
total_read = total_read.saturating_add(layer_size);
242+
total_read = total_read.saturating_add(actual_size);
240243
// Emit an event where bytes == total to signal completion.
241-
subtask.bytes = layer_size;
244+
subtask.bytes_total = actual_size;
245+
subtask.bytes = actual_size;
242246
subtasks.push(subtask.clone());
243247
config.prog.send(Event::ProgressBytes {
244248
task: "pulling".into(),
@@ -268,7 +272,12 @@ async fn handle_layer_progress_print(mut config: LayerProgressConfig) -> Progres
268272
bytes.as_ref().cloned()
269273
};
270274
if let Some(bytes) = bytes {
275+
// Update the bar length from the actual blob size, which
276+
// may differ from the manifest descriptor size (e.g.
277+
// containers-storage stores layers uncompressed).
278+
byte_bar.set_length(bytes.total);
271279
byte_bar.set_position(bytes.fetched);
280+
subtask.bytes_total = bytes.total;
272281
subtask.bytes = byte_bar.position();
273282
config.prog.send_lossy(Event::ProgressBytes {
274283
task: "pulling".into(),

0 commit comments

Comments
 (0)