[gnome-software] trivial: Delete dangling symlinks in the flatpak cache refresh



commit 808b7000ee220576f869c37ebe4da6dbcd7edfbe
Author: Richard Hughes <richard hughsie com>
Date:   Mon Jun 13 17:19:33 2016 +0100

    trivial: Delete dangling symlinks in the flatpak cache refresh

 src/plugins/gs-flatpak-symlinks.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/src/plugins/gs-flatpak-symlinks.c b/src/plugins/gs-flatpak-symlinks.c
index ee0e482..da1a82a 100644
--- a/src/plugins/gs-flatpak-symlinks.c
+++ b/src/plugins/gs-flatpak-symlinks.c
@@ -80,12 +80,6 @@ gs_flatpak_symlinks_check_exist (FlatpakRemote *xremote,
                                                   "icons",
                                                   NULL);
        }
-       if (!g_file_test (symlink_target, G_FILE_TEST_EXISTS)) {
-               g_debug ("remote %s has no %s, skipping",
-                        flatpak_remote_get_name (xremote),
-                        symlink_target);
-               return TRUE;
-       }
        symlink_source = g_build_filename (subdir,
                                           flatpak_remote_fn,
                                           NULL);
@@ -93,11 +87,18 @@ gs_flatpak_symlinks_check_exist (FlatpakRemote *xremote,
                return FALSE;
 
        /* check XML symbolic link is correct */
-       if (g_file_test (symlink_source, G_FILE_TEST_EXISTS)) {
+       if (g_file_test (symlink_source, G_FILE_TEST_IS_SYMLINK)) {
                g_autofree gchar *symlink_target_actual = NULL;
 
-               /* same */
+               /* target does not exist */
                symlink_target_actual = g_file_read_link (symlink_source, NULL);
+               if (!g_file_test (symlink_target_actual, G_FILE_TEST_EXISTS)) {
+                       g_debug ("symlink %s is dangling (no %s), deleting",
+                                 symlink_source, symlink_target_actual);
+                       return gs_utils_unlink (symlink_source, error);
+               }
+
+               /* same */
                if (g_strcmp0 (symlink_target_actual, symlink_target) == 0) {
                        g_debug ("symlink %s already points to %s",
                                 symlink_source, symlink_target);


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