After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 695294 - Report progress of already running downloads
Report progress of already running downloads
Status: RESOLVED FIXED
Product: gnome-boxes
Classification: Applications
Component: wizard
unspecified
Other All
: Normal normal
: 3.22
Assigned To: GNOME Boxes maintainer(s)
GNOME Boxes maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2013-03-06 14:13 UTC by Zeeshan Ali
Modified: 2016-03-31 13:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
downloader: Rename download method to download_remote_file (2.82 KB, patch)
2013-03-06 14:13 UTC, Zeeshan Ali
rejected Details | Review
downloader: Add a utility Download class (7.20 KB, patch)
2013-03-06 14:13 UTC, Zeeshan Ali
committed Details | Review
downloader: Report progress of already running downloads (1.86 KB, patch)
2013-03-06 14:13 UTC, Zeeshan Ali
none Details | Review
downloader: Report progress of already running downloads (2.68 KB, patch)
2013-03-07 14:04 UTC, Zeeshan Ali
committed Details | Review

Description Zeeshan Ali 2013-03-06 14:13:24 UTC
See patches (especially last one).
Comment 1 Zeeshan Ali 2013-03-06 14:13:26 UTC
Created attachment 238200 [details] [review]
downloader: Rename download method to download_remote_file

The following patch will add variables and parameters of the same name
and I couldn't think of a better name for those so I decided to rename
this method instead.
Comment 2 Zeeshan Ali 2013-03-06 14:13:29 UTC
Created attachment 238201 [details] [review]
downloader: Add a utility Download class

A new private class that keeps info about each download, including its
progress. In following patch we'll make use of this to report progress
of already running downloads (which we currently don't).
Comment 3 Zeeshan Ali 2013-03-06 14:13:34 UTC
Created attachment 238202 [details] [review]
downloader: Report progress of already running downloads

This is actually more like reporting progress of duplicate downloads.
Comment 4 Christophe Fergeau 2013-03-07 10:15:03 UTC
Review of attachment 238202 [details] [review]:

Would be nice to add concrete descriptions of when this happens. Apparently this hits because we now download drivers at boxes startup in the background, so if someone starts boxes, and then starts gnome-boxes ./win.iso, then the latter will not show download progress
Comment 5 Christophe Fergeau 2013-03-07 10:49:49 UTC
Review of attachment 238200 [details] [review]:

Why is it needed? As long as you are not adding a method with the same name, this shouldn't clash. I've tried that reverting this patch on top of the series does not break the build
Comment 6 Christophe Fergeau 2013-03-07 10:56:11 UTC
Review of attachment 238202 [details] [review]:

Looks good with a better commitlog
Comment 7 Christophe Fergeau 2013-03-07 13:32:22 UTC
Review of attachment 238201 [details] [review]:

Looks good otherwise

::: src/downloader.vala
@@ +59,3 @@
                                             ActivityProgress progress = new ActivityProgress ()) throws GLib.Error {
         var uri = remote_file.get_uri ();
+        var download = downloads.get (uri);

Slight preference for Download download there, this makes things easier if for example we need to pass 'download' to a helper function, no need to guess the type, it's already right there.
Comment 8 Zeeshan Ali 2013-03-07 13:48:49 UTC
Review of attachment 238200 [details] [review]:

The issue isn't exactly clashing in the following patch itself but more of confusion/readability.
Comment 9 Zeeshan Ali 2013-03-07 13:50:37 UTC
Review of attachment 238201 [details] [review]:

::: src/downloader.vala
@@ +59,3 @@
                                             ActivityProgress progress = new ActivityProgress ()) throws GLib.Error {
         var uri = remote_file.get_uri ();
+        var download = downloads.get (uri);

Well my preference is the opposite here and as you can see from the rest of the code and CodingStyle.txt, this is the prefered way for the project. Since its not really a big deal, we don't force it on your patches. :)
Comment 10 Zeeshan Ali 2013-03-07 14:04:36 UTC
Created attachment 238294 [details] [review]
downloader: Report progress of already running downloads

v2: Better commit log.
Comment 11 Zeeshan Ali 2013-03-07 14:19:02 UTC
Review of attachment 238201 [details] [review]:

::: src/downloader.vala
@@ +59,3 @@
                                             ActivityProgress progress = new ActivityProgress ()) throws GLib.Error {
         var uri = remote_file.get_uri ();
+        var download = downloads.get (uri);

Whereas the arguments are concerned, instead of looking at declaration of the variable, you look at the declaration/definition of the function (in this case, the declaration of 'downloads' hashtable). So only slightly inconveniently to find out the type but not enough to varant to have to type the Type for every variable. IMO, this is a very good balance between extreme verbosity of strong-typed languages and extreme flexibility of dynamic languages.

Not trying to convince you, just putting it on the record that I have reasons for my preference. :)
Comment 12 Christophe Fergeau 2013-03-07 14:22:47 UTC
Review of attachment 238200 [details] [review]:

I'd rather we keep the best name for the public method, and change the internal names if you don't want to use download everywhere (I don't particularly mind). 'dload' instead of 'download' for the local variable maybe?
Comment 13 Christophe Fergeau 2013-03-07 14:29:42 UTC
Review of attachment 238201 [details] [review]:

::: src/downloader.vala
@@ +59,3 @@
                                             ActivityProgress progress = new ActivityProgress ()) throws GLib.Error {
         var uri = remote_file.get_uri ();
+        var download = downloads.get (uri);

Well, in this case it's not too bad, it can get quite convoluted with stuff like var foo = get_foo_singleton().get_foo() where you have to hunt down get_foo_singleton() type in some external lib, and then the type returned by get_foo() once you have that type.

Using var everywhere is not a 'very good' balance, it's heavily skewed toward the convenience of the code writer, and detrimental to future code maintainance, the very good balance is when you use var only when using a constructor, and explicit types everywhere else.

Given that what a 'very good balance' is is highly subjective, let's keep it at that.
Comment 14 Christophe Fergeau 2013-03-07 14:35:22 UTC
Review of attachment 238294 [details] [review]:

After the discussion on IRC, it seems we'll soon no longer have parallel downloads going on, but these changes seem worthwhile to have anyway, make the Download code more flexible.
Comment 15 Zeeshan Ali 2013-03-07 15:04:36 UTC
Attachment 238201 [details] pushed as fc9a17a - downloader: Add a utility Download class
Attachment 238294 [details] pushed as 48e2bb5 - downloader: Report progress of already running downloads