[gnome-remote-desktop] credentials/file: Don't report error when clearing non-existing credentials



commit d693e7a868178accb3ecf3d73f90957056b69ece
Author: Jonas Ådahl <jadahl gmail com>
Date:   Fri Sep 2 20:42:42 2022 +0200

    credentials/file: Don't report error when clearing non-existing credentials

 src/grd-credentials-file.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/src/grd-credentials-file.c b/src/grd-credentials-file.c
index 9f9ef302..48a2d355 100644
--- a/src/grd-credentials-file.c
+++ b/src/grd-credentials-file.c
@@ -105,14 +105,30 @@ grd_credentials_file_clear (GrdCredentials      *credentials,
                             GError             **error)
 {
   GrdCredentialsFile *credentials_file = GRD_CREDENTIALS_FILE (credentials);
+  g_autoptr (GError) local_error = NULL;
   gboolean removed;
 
   removed = g_key_file_remove_key (credentials_file->key_file,
                                    group_name_from_type (type),
-                                   GRD_CREDENTIALS_FILE_KEY, error);
+                                   GRD_CREDENTIALS_FILE_KEY, &local_error);
+  if (!removed)
+    {
+      if (!g_error_matches (local_error,
+                            G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND) &&
+          !g_error_matches (local_error,
+                            G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND))
+        {
+          g_propagate_error (error, g_steal_pointer (&local_error));
+          return FALSE;
+        }
+      else
+        {
+          return TRUE;
+        }
+    }
 
-  return removed && g_key_file_save_to_file (credentials_file->key_file,
-                                             credentials_file->filename, error);
+  return g_key_file_save_to_file (credentials_file->key_file,
+                                  credentials_file->filename, error);
 }
 
 GrdCredentialsFile *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]