[gnome-software/1528-stuck-at-loading-application-details] gs_utils_get_file_size: Do not follow symlinks



commit 83f22b7dfb9ba6759a0a73ce6fea76ec0f509f0f
Author: Milan Crha <mcrha redhat com>
Date:   Fri Nov 5 11:11:04 2021 +0100

    gs_utils_get_file_size: Do not follow symlinks
    
    The symlinks can point to a shared storage, or even out of the directory,
    whose size is being calculated, thus skip them, to have more accurate
    information about the directory size.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1528

 lib/gs-utils.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/lib/gs-utils.c b/lib/gs-utils.c
index ec4092ba0..7c5b49593 100644
--- a/lib/gs-utils.c
+++ b/lib/gs-utils.c
@@ -1490,12 +1490,14 @@ gs_utils_get_file_size (const gchar *filename,
 
                                        if (g_stat (full_path, &st) == 0 && (include_func == NULL ||
                                            include_func (full_path + base_len,
-                                                         S_ISLNK (st.st_mode) ? G_FILE_TEST_IS_SYMLINK :
+                                                         g_file_test (full_path, G_FILE_TEST_IS_SYMLINK) ? 
G_FILE_TEST_IS_SYMLINK :
                                                          S_ISDIR (st.st_mode) ? G_FILE_TEST_IS_DIR :
                                                          G_FILE_TEST_IS_REGULAR,
                                                          user_data))) {
                                                if (S_ISDIR (st.st_mode)) {
-                                                       dirs_to_do = g_slist_prepend (dirs_to_do, 
g_steal_pointer (&full_path));
+                                                       /* Skip symlinks, they can point to a shared storage 
*/
+                                                       if (!g_file_test (full_path, G_FILE_TEST_IS_SYMLINK))
+                                                               dirs_to_do = g_slist_prepend (dirs_to_do, 
g_steal_pointer (&full_path));
                                                } else {
                                                        size += st.st_size;
                                                }


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