diff options
author | Iceyer <me@iceyer.net> | 2018-01-22 13:38:50 +0800 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2018-01-30 11:32:42 +0100 |
commit | 85cda5d2037521d5163c6a2e2bca75b564a4fc12 (patch) | |
tree | 30231c03e396a119d3cde515f590349d07561474 | |
parent | 75f2c63ced78a09b56cfe6d9f751defe442d0ac6 (diff) | |
download | flatpak-85cda5d2037521d5163c6a2e2bca75b564a4fc12.tar.gz |
common: Fix division by zero when calculate progress
Closes: #1331
Approved by: alexlarsson
(cherry picked from commit 1cea02a2f6455ec7dd247ec099509b11dc4520bd)
-rw-r--r-- | common/flatpak-utils.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/common/flatpak-utils.c b/common/flatpak-utils.c index 56b5e672..92fab574 100644 --- a/common/flatpak-utils.c +++ b/common/flatpak-utils.c @@ -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); |