[gnome-software] fwupd: Only delete the installed archive if we downloaded it to the cache
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] fwupd: Only delete the installed archive if we downloaded it to the cache
- Date: Wed, 29 Apr 2020 18:38:55 +0000 (UTC)
commit 42e29341213e9bb18c69192d87b399ad4de3ea21
Author: Richard Hughes <richard hughsie com>
Date: Wed Apr 29 12:54:04 2020 +0100
fwupd: Only delete the installed archive if we downloaded it to the cache
If the user double clicks on a .cab file on a USB stick to install it, it is
certainly not expected we delete the archive when it has been scheduled.
plugins/fwupd/gs-plugin-fwupd.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/plugins/fwupd/gs-plugin-fwupd.c b/plugins/fwupd/gs-plugin-fwupd.c
index a5e2671c..15e2b4b6 100644
--- a/plugins/fwupd/gs-plugin-fwupd.c
+++ b/plugins/fwupd/gs-plugin-fwupd.c
@@ -767,6 +767,7 @@ gs_plugin_fwupd_install (GsPlugin *plugin,
FwupdInstallFlags install_flags = 0;
GFile *local_file;
g_autofree gchar *filename = NULL;
+ gboolean downloaded_to_cache = FALSE;
/* not set */
local_file = gs_app_get_local_file (app);
@@ -787,6 +788,7 @@ gs_plugin_fwupd_install (GsPlugin *plugin,
if (!gs_plugin_download_file (plugin, app, uri, filename,
cancellable, error))
return FALSE;
+ downloaded_to_cache = TRUE;
}
/* limit to single device? */
@@ -812,7 +814,13 @@ gs_plugin_fwupd_install (GsPlugin *plugin,
/* delete the file from the cache */
gs_app_set_state (app, AS_APP_STATE_INSTALLED);
- return g_file_delete (local_file, cancellable, error);
+ if (downloaded_to_cache) {
+ if (!g_file_delete (local_file, cancellable, error))
+ return FALSE;
+ }
+
+ /* success */
+ return TRUE;
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]