Blame SOURCES/0056-app-Always-add-guest-name-comment.patch

427fab
From 1397ef78ac43e971cef317893f9fe597bf7074ed Mon Sep 17 00:00:00 2001
427fab
From: Victor Toso <me@victortoso.com>
427fab
Date: Thu, 30 Aug 2018 13:51:17 +0200
427fab
Subject: [PATCH] app: Always add guest name comment
427fab
427fab
Even when the user adds comments, we should place the guest's name
427fab
unless it is present already.
427fab
427fab
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1623756
427fab
427fab
Signed-off-by: Victor Toso <victortoso@redhat.com>
427fab
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
427fab
(cherry picked from commit 7ffb7f9cf485f6eefacccf6b20167b0d67521ebb)
427fab
---
427fab
 src/virt-viewer-app.c | 10 +++++++---
427fab
 1 file changed, 7 insertions(+), 3 deletions(-)
427fab
427fab
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
427fab
index e90afe8..6f17842 100644
427fab
--- a/src/virt-viewer-app.c
427fab
+++ b/src/virt-viewer-app.c
427fab
@@ -258,9 +258,13 @@ virt_viewer_app_save_config(VirtViewerApp *self)
427fab
         if (error) {
427fab
             g_debug("Unable to get comment from key file: %s", error->message);
427fab
             g_clear_error(&error);
427fab
-        } else {
427fab
-            if (!comment || *comment == '\0')
427fab
-                g_key_file_set_comment(priv->config, priv->uuid, NULL, priv->guest_name, NULL);
427fab
+        }
427fab
+
427fab
+        if (comment == NULL ||
427fab
+                (comment != NULL && g_strstr_len(comment, -1, priv->guest_name) == NULL)) {
427fab
+            /* Note that this function appends the guest's name string as last
427fab
+             * comment in case there were comments there already */
427fab
+            g_key_file_set_comment(priv->config, priv->uuid, NULL, priv->guest_name, NULL);
427fab
         }
427fab
         g_free(comment);
427fab
     }