Add a command 'clear-offline' to fwupdmgr

This allows us to 'unschedule' any offline updates.
This commit is contained in:
Richard Hughes 2017-09-15 09:30:46 +01:00
parent f6e4d723ca
commit 31bbd1691b
3 changed files with 44 additions and 0 deletions

View File

@ -185,6 +185,35 @@ out:
return ret;
}
gboolean
fu_pending_remove_all (FuPending *pending, GError **error)
{
FuPendingPrivate *priv = GET_PRIVATE (pending);
char *error_msg = NULL;
gint rc;
g_return_val_if_fail (FU_IS_PENDING (pending), FALSE);
/* lazy load */
if (priv->db == NULL) {
if (!fu_pending_load (pending, error))
return FALSE;
}
/* remove entries */
g_debug ("FuPending: removing all devices");
rc = sqlite3_exec (priv->db, "DELETE FROM pending;", NULL, NULL, &error_msg);
if (rc != SQLITE_OK) {
g_set_error (error,
FWUPD_ERROR,
FWUPD_ERROR_WRITE,
"SQL error: %s", error_msg);
sqlite3_free (error_msg);
return FALSE;
}
return TRUE;
}
gboolean
fu_pending_remove_device (FuPending *pending, FwupdResult *res, GError **error)
{

View File

@ -52,6 +52,8 @@ gboolean fu_pending_set_error_msg (FuPending *pending,
gboolean fu_pending_remove_device (FuPending *pending,
FwupdResult *res,
GError **error);
gboolean fu_pending_remove_all (FuPending *pending,
GError **error);
FwupdResult *fu_pending_get_device (FuPending *pending,
const gchar *device_id,
GError **error);

View File

@ -557,6 +557,13 @@ fu_util_clear_results (FuUtilPrivate *priv, gchar **values, GError **error)
return fwupd_client_clear_results (priv->client, values[0], NULL, error);
}
static gboolean
fu_util_clear_offline (FuUtilPrivate *priv, gchar **values, GError **error)
{
g_autoptr(FuPending) pending = fu_pending_new ();
return fu_pending_remove_all (pending, error);
}
static gboolean
fu_util_verify_update_all (FuUtilPrivate *priv, GError **error)
{
@ -1705,6 +1712,12 @@ main (int argc, char *argv[])
/* TRANSLATORS: command description */
_("Clears the results from the last update"),
fu_util_clear_results);
fu_util_add (priv->cmd_array,
"clear-offline",
NULL,
/* TRANSLATORS: command description */
_("Clears any updates scheduled to be updated offline"),
fu_util_clear_offline);
fu_util_add (priv->cmd_array,
"get-results",
NULL,