[gnome-boxes/gnome-3-14] downloader: Handle downloads of unknown size
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/gnome-3-14] downloader: Handle downloads of unknown size
- Date: Wed, 15 Oct 2014 00:18:12 +0000 (UTC)
commit f3cf6b064d4d07197340f83d627ffd54a271c777
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Mon Oct 13 18:48:09 2014 +0100
downloader: Handle downloads of unknown size
Currently if size of file being downloaded is unknown, we download the
bytes but just ignore the bytes. This patch fixes this case by writing
the downloaded bytes to the file but just not reporting progress if size
is unknown.
src/downloader.vala | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
---
diff --git a/src/downloader.vala b/src/downloader.vala
index 614f6f9..f64b1b7 100644
--- a/src/downloader.vala
+++ b/src/downloader.vala
@@ -137,16 +137,15 @@ private class Boxes.Downloader : GLib.Object {
int64 current_num_bytes = 0;
// FIXME: Reduce lambda nesting by splitting out downloading to Download class
msg.got_chunk.connect ((msg, chunk) => {
- if (total_num_bytes <= 0)
- return;
-
current_num_bytes += chunk.length;
try {
// Write synchronously as we have no control over order of async
// calls and we'll end up writing bytes out in wrong order. Besides
// we are writing small chunks so it wouldn't really block the UI.
cached_file_stream.write (chunk.data);
- download.progress.progress = (double) current_num_bytes / total_num_bytes;
+ if (total_num_bytes > 0)
+ // Don't report progress if there is no way to determine it
+ download.progress.progress = (double) current_num_bytes / total_num_bytes;
} catch (GLib.Error e) {
err = e;
session.cancel_message (msg, Soup.Status.CANCELLED);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]