mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-16 07:25:43 +00:00
trivial: Add the ability to download files using PkClient for testing
This commit is contained in:
parent
3d6a48fad3
commit
eb215753ee
@ -6,6 +6,7 @@ _fwupdmgr_cmd_list=(
|
|||||||
'clear-results'
|
'clear-results'
|
||||||
'disable-remote'
|
'disable-remote'
|
||||||
'downgrade'
|
'downgrade'
|
||||||
|
'download'
|
||||||
'enable-remote'
|
'enable-remote'
|
||||||
'get-approved-firmware'
|
'get-approved-firmware'
|
||||||
'get-blocked-firmware'
|
'get-blocked-firmware'
|
||||||
|
@ -674,6 +674,35 @@ fu_util_display_current_message (FuUtilPrivate *priv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
fu_util_download(FuUtilPrivate *priv, gchar **values, GError **error)
|
||||||
|
{
|
||||||
|
g_autofree gchar *basename = NULL;
|
||||||
|
g_autoptr(GBytes) blob = NULL;
|
||||||
|
|
||||||
|
/* one argument required */
|
||||||
|
if (g_strv_length(values) != 1) {
|
||||||
|
g_set_error_literal(error,
|
||||||
|
FWUPD_ERROR,
|
||||||
|
FWUPD_ERROR_INVALID_ARGS,
|
||||||
|
"Invalid arguments");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
blob = fwupd_client_download_bytes(priv->client,
|
||||||
|
values[0],
|
||||||
|
priv->download_flags,
|
||||||
|
priv->cancellable,
|
||||||
|
error);
|
||||||
|
if (blob == NULL)
|
||||||
|
return FALSE;
|
||||||
|
basename = g_path_get_basename(values[0]);
|
||||||
|
return g_file_set_contents(basename,
|
||||||
|
g_bytes_get_data(blob, NULL),
|
||||||
|
g_bytes_get_size(blob),
|
||||||
|
error);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_util_install (FuUtilPrivate *priv, gchar **values, GError **error)
|
fu_util_install (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||||
{
|
{
|
||||||
@ -3344,6 +3373,13 @@ main (int argc, char *argv[])
|
|||||||
/* TRANSLATORS: command description */
|
/* TRANSLATORS: command description */
|
||||||
_("Get all enabled plugins registered with the system"),
|
_("Get all enabled plugins registered with the system"),
|
||||||
fu_util_get_plugins);
|
fu_util_get_plugins);
|
||||||
|
fu_util_cmd_array_add(cmd_array,
|
||||||
|
"download",
|
||||||
|
/* TRANSLATORS: command argument: uppercase, spaces->dashes */
|
||||||
|
_("LOCATION"),
|
||||||
|
/* TRANSLATORS: command description */
|
||||||
|
_("Download a file"),
|
||||||
|
fu_util_download);
|
||||||
|
|
||||||
/* do stuff on ctrl+c */
|
/* do stuff on ctrl+c */
|
||||||
priv->cancellable = g_cancellable_new ();
|
priv->cancellable = g_cancellable_new ();
|
||||||
|
Loading…
Reference in New Issue
Block a user