fwupdtool/fwupdmgr: make return code different for get-updates with no updates

This allows other tools to depend on it when checking for updates rather than
reading the output.
This commit is contained in:
Mario Limonciello 2020-09-30 16:31:03 -05:00 committed by Mario Limonciello
parent 406025ba56
commit e8946a74d1
2 changed files with 23 additions and 9 deletions

View File

@ -485,13 +485,20 @@ fu_util_get_updates (FuUtilPrivate *priv, gchar **values, GError **error)
g_node_append_data (child, g_object_ref (rel));
}
}
if (g_node_n_nodes (root, G_TRAVERSE_ALL) > 1)
fu_util_print_tree (root, title);
/* save the device state for other applications to see */
if (!fu_util_save_current_state (priv, error))
return FALSE;
/* success */
/* updates */
if (g_node_n_nodes (root, G_TRAVERSE_ALL) <= 1) {
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_NOTHING_TO_DO,
"No updates available for remaining devices");
return FALSE;
}
fu_util_print_tree (root, title);
return TRUE;
}

View File

@ -1442,9 +1442,6 @@ fu_util_get_updates (FuUtilPrivate *priv, gchar **values, GError **error)
}
}
if (g_node_n_nodes (root, G_TRAVERSE_ALL) > 1)
fu_util_print_tree (root, title);
/* nag? */
if (!fu_util_perhaps_show_unreported (priv, error))
return FALSE;
@ -1452,11 +1449,21 @@ fu_util_get_updates (FuUtilPrivate *priv, gchar **values, GError **error)
/* no devices supported by LVFS or all are filtered */
if (!supported) {
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_NOTHING_TO_DO,
"No updatable devices");
FWUPD_ERROR,
FWUPD_ERROR_NOTHING_TO_DO,
"No updatable devices");
return FALSE;
}
/* no updates available */
if (g_node_n_nodes (root, G_TRAVERSE_ALL) <= 1) {
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_NOTHING_TO_DO,
"No updates available for remaining devices");
return FALSE;
}
fu_util_print_tree (root, title);
/* success */
return TRUE;