[gnome-software/gnome-3-22] fwupd: Download the firmware update manually if not yet downloaded



commit e67fe25ab76d33808928dcc7117a46a50f2d1f8a
Author: Richard Hughes <richard hughsie com>
Date:   Fri Oct 21 16:32:23 2016 +0100

    fwupd: Download the firmware update manually if not yet downloaded
    
    There is no way this can happen right now, but in the future...
    
    (cherry picked from commit 8712ae177ee3cdb7f71ae1770a8d259816ccf565)

 src/plugins/gs-plugin-fwupd.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/gs-plugin-fwupd.c b/src/plugins/gs-plugin-fwupd.c
index f06ce9f..ed3bc11 100644
--- a/src/plugins/gs-plugin-fwupd.c
+++ b/src/plugins/gs-plugin-fwupd.c
@@ -361,6 +361,8 @@ gs_plugin_fwupd_new_app_from_results (GsPlugin *plugin, FwupdResult *res)
        if (fwupd_result_get_update_uri (res) != NULL) {
                gs_app_set_origin_hostname (app,
                                            fwupd_result_get_update_uri (res));
+               gs_app_set_metadata (app, "fwupd::UpdateURI",
+                                    fwupd_result_get_update_uri (res));
        }
        if (fwupd_result_get_device_description (res) != NULL) {
                g_autofree gchar *tmp = NULL;
@@ -741,10 +743,12 @@ gs_plugin_fwupd_install (GsPlugin *plugin,
        GsPluginData *priv = gs_plugin_get_data (plugin);
        const gchar *device_id;
        FwupdInstallFlags install_flags = 0;
+       GFile *local_file;
        g_autofree gchar *filename = NULL;
 
        /* not set */
-       if (gs_app_get_local_file (app) == NULL) {
+       local_file = gs_app_get_local_file (app);
+       if (local_file == NULL) {
                g_set_error (error,
                             GS_PLUGIN_ERROR,
                             GS_PLUGIN_ERROR_FAILED,
@@ -752,7 +756,15 @@ gs_plugin_fwupd_install (GsPlugin *plugin,
                             filename);
                return FALSE;
        }
-       filename = g_file_get_path (gs_app_get_local_file (app));
+
+       /* file does not yet exist */
+       filename = g_file_get_path (local_file);
+       if (!g_file_query_exists (local_file, cancellable)) {
+               const gchar *uri = gs_app_get_metadata_item (app, "fwupd::UpdateURI");
+               if (!gs_plugin_download_file (plugin, app, uri, filename,
+                                             cancellable, error))
+                       return FALSE;
+       }
 
        /* limit to single device? */
        device_id = gs_app_get_metadata_item (app, "fwupd::DeviceID");


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