Skip to content

Commit 395f8f5

Browse files
ilopezlunadoringeman
authored andcommitted
Report finish update (docker#101)
1 parent cb0d329 commit 395f8f5

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

pkg/distribution/internal/progress/reporter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ func (r *Reporter) Updates() chan<- v1.Update {
104104

105105
// Only update if enough time has passed or enough bytes downloaded or finished
106106
if now.Sub(lastUpdate) >= UpdateInterval ||
107-
incrementalBytes >= MinBytesForUpdate {
107+
incrementalBytes >= MinBytesForUpdate ||
108+
safeUint64(p.Complete) == layerSize {
108109
if err := WriteProgress(r.out, r.format(p), r.imageSize, layerSize, safeUint64(p.Complete), layerID); err != nil {
109110
r.err = err
110111
}

pkg/distribution/internal/progress/reporter_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,22 @@ func TestProgressEmissionScenarios(t *testing.T) {
188188
},
189189
expectedCount: 1, // Only first update
190190
description: "should not emit updates if too frequent",
191-
layerSize: 100,
191+
layerSize: 200,
192+
},
193+
{
194+
name: "finsh update",
195+
updates: []v1.Update{
196+
{Complete: 100}, // First update always sent
197+
{Complete: 100}, // Too frequent, no update
198+
{Complete: 200}, // Too frequent, but finished, report update
199+
},
200+
delays: []time.Duration{
201+
10 * time.Millisecond, // Too short
202+
10 * time.Millisecond, // Too short
203+
},
204+
expectedCount: 2, // first and last update
205+
description: "should emit updates if finished",
206+
layerSize: 200,
192207
},
193208
{
194209
name: "no updates - too few bytes",

0 commit comments

Comments
 (0)