mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-15 08:18:10 +00:00
Do not re-download firmware that exists in the cache
This commit is contained in:
parent
01c13d1634
commit
502a2ca64a
@ -581,6 +581,22 @@ fu_util_verify_update (FuUtilPrivate *priv, gchar **values, GError **error)
|
|||||||
return fwupd_client_verify_update (priv->client, values[0], NULL, error);
|
return fwupd_client_verify_update (priv->client, values[0], NULL, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
fu_util_file_exists_with_checksum (const gchar *fn,
|
||||||
|
const gchar *checksum_expected,
|
||||||
|
GChecksumType checksum_type)
|
||||||
|
{
|
||||||
|
gsize len = 0;
|
||||||
|
g_autofree gchar *checksum_actual = NULL;
|
||||||
|
g_autofree gchar *data = NULL;
|
||||||
|
|
||||||
|
if (!g_file_get_contents (fn, &data, &len, NULL))
|
||||||
|
return FALSE;
|
||||||
|
checksum_actual = g_compute_checksum_for_data (checksum_type,
|
||||||
|
(guchar *) data, len);
|
||||||
|
return g_strcmp0 (checksum_expected, checksum_actual) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_util_download_file (FuUtilPrivate *priv,
|
fu_util_download_file (FuUtilPrivate *priv,
|
||||||
SoupURI *uri,
|
SoupURI *uri,
|
||||||
@ -598,6 +614,12 @@ fu_util_download_file (FuUtilPrivate *priv,
|
|||||||
g_autoptr(SoupMessage) msg = NULL;
|
g_autoptr(SoupMessage) msg = NULL;
|
||||||
g_autoptr(SoupSession) session = NULL;
|
g_autoptr(SoupSession) session = NULL;
|
||||||
|
|
||||||
|
/* check if the file already exists with the right checksum */
|
||||||
|
if (fu_util_file_exists_with_checksum (fn, checksum_expected, checksum_type)) {
|
||||||
|
g_debug ("skpping download as file already exists");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* create the soup session */
|
/* create the soup session */
|
||||||
user_agent = g_strdup_printf ("%s/%s", PACKAGE_NAME, PACKAGE_VERSION);
|
user_agent = g_strdup_printf ("%s/%s", PACKAGE_NAME, PACKAGE_VERSION);
|
||||||
session = soup_session_new_with_options (SOUP_SESSION_USER_AGENT, user_agent,
|
session = soup_session_new_with_options (SOUP_SESSION_USER_AGENT, user_agent,
|
||||||
|
Loading…
Reference in New Issue
Block a user