common: Fix division by zero when calculate progress

Closes: #1331
Approved by: alexlarsson
This commit is contained in:
Iceyer
2018-01-22 13:38:50 +08:00
committed by Atomic Bot
parent 30e5bbc45f
commit 1cea02a2f6

View File

@@ -6573,7 +6573,11 @@ progress_cb (OstreeAsyncProgress *progress, gpointer user_data)
}
/* The download progress goes up to 97% */
new_progress = 5 + ((total_transferred / (gdouble) total) * 92);
if (total > 0) {
new_progress = 5 + ((total_transferred / (gdouble) total) * 92);
} else {
new_progress = 97;
}
/* And the writing of the objects adds 3% to the progress */
new_progress += get_write_progress (outstanding_writes);