[gnome-boxes/wip/rishi/rhel: 9/13] downloader, wizard: Support a custom filename for downloaded media



commit 5989b236dffc94ef9345865a62eb3cf18ee984ad
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Aug 31 20:24:35 2017 +0200

    downloader, wizard: Support a custom filename for downloaded media
    
    https://bugzilla.gnome.org/show_bug.cgi?id=786679

 src/downloader.vala |   10 +++++++++-
 src/wizard.vala     |    2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/downloader.vala b/src/downloader.vala
index 86fac3b..6ca8251 100644
--- a/src/downloader.vala
+++ b/src/downloader.vala
@@ -205,10 +205,18 @@ private class Boxes.Downloader : GLib.Object {
     }
 
     public static async string fetch_media (string           uri,
+                                            string?          filename = null,
                                             ActivityProgress progress = new ActivityProgress (),
                                             Cancellable?     cancellable = null) throws GLib.Error {
         var file = File.new_for_uri (uri);
-        var basename = file.get_basename ();
+        string? basename = null;
+
+        if (filename == null) {
+            basename = file.get_basename ();
+        } else {
+            basename = filename;
+        }
+
         return_val_if_fail (basename != null && basename != "" && basename != "/", null);
 
         var downloader = Downloader.get_instance ();
diff --git a/src/wizard.vala b/src/wizard.vala
index 069004c..5cb9b93 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -601,7 +601,7 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
         prep_status_label.label = _("Downloading media…");
 
         try {
-            var cache_path = yield Downloader.fetch_media (uri, download_progress, prepare_cancellable);
+            var cache_path = yield Downloader.fetch_media (uri, null, download_progress, 
prepare_cancellable);
             prepare_downloaded_media (cache_path, progress);
         } catch (GLib.IOError.CANCELLED e) {
             debug ("Cancelled downloading media '%s'!", uri);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]