Skip to content

Commit 1d7e5f5

Browse files
fix(downloads): correctly report progress for components that were already downloaded
1 parent b4aa5ee commit 1d7e5f5

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/cli/download_tracker.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,12 @@ impl DownloadTracker {
133133
return;
134134
};
135135
pb.set_style(
136-
ProgressStyle::with_template("{msg:>12.bold} downloaded {total_bytes} in {elapsed}")
137-
.unwrap(),
136+
ProgressStyle::with_template(if pb.position() != 0 {
137+
"{msg:>12.bold} downloaded {total_bytes} in {elapsed}"
138+
} else {
139+
"{msg:>12.bold} component already downloaded"
140+
})
141+
.unwrap(),
138142
);
139143
}
140144

@@ -170,8 +174,11 @@ impl DownloadTracker {
170174
&& let Some((pb, _)) = self.file_progress_bars.get(&key)
171175
{
172176
pb.set_style(
173-
ProgressStyle::with_template(
174-
"{msg:>12.bold} downloaded {total_bytes} in {elapsed} installing now {spinner:.green}",
177+
ProgressStyle::with_template( if pb.position() != 0 {
178+
"{msg:>12.bold} downloaded {total_bytes} in {elapsed} installing now {spinner:.green}"
179+
} else {
180+
"{msg:>12.bold} component already downloaded, installing now {spinner:.green}"
181+
}
175182
)
176183
.unwrap()
177184
.tick_chars(r"|/-\ "),
@@ -191,9 +198,11 @@ impl DownloadTracker {
191198
&& let Some((pb, _)) = self.file_progress_bars.get(&key)
192199
{
193200
pb.set_style(
194-
ProgressStyle::with_template(
195-
"{msg:>12.bold} downloaded {total_bytes} and installed",
196-
)
201+
ProgressStyle::with_template(if pb.position() != 0 {
202+
"{msg:>12.bold} downloaded {total_bytes} and installed"
203+
} else {
204+
"{msg:>12.bold} component already downloaded and installed"
205+
})
197206
.unwrap(),
198207
);
199208
pb.finish();

0 commit comments

Comments
 (0)