[gnome-boxes] downloader: Handle downloads of unknown size
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] downloader: Handle downloads of unknown size
- Date: Mon, 13 Oct 2014 17:52:04 +0000 (UTC)
commit 612d7d90344ddf8b996041757b49eda359c468a7
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 191ee26..d965815 100644
--- a/src/downloader.vala
+++ b/src/downloader.vala
@@ -141,16 +141,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]