[glib/glib-2-68: 1/2] glocalfile: Fix the global trash dir detection




commit d7ba35360a3e25e23e251b4c52e948af58a0a479
Author: markus <markus schwarzenberg freenet de>
Date:   Mon Jul 12 00:16:20 2021 +0200

    glocalfile: Fix the global trash dir detection
    
    The `g_file_trash` function fails with the `Unable to find or create trash
    directory` error when the global `.Trash` directory exists. This is because
    the commit 7f2af262 introduced the `gboolean success` variable to signalize
    the detection of the trash folder, but didn't set it in all code branches.
    Since for a time this variable was not initialized the bug wasn't visible
    when the trash folder existed. The bug became effective after the `success`
    variable was initialized with `FALSE` by the commit c983ded0. Let's explicitly
    set the `success` variable in all branches to fix the global trash dir
    detection.
    
    Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2439

 gio/glocalfile.c | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/gio/glocalfile.c b/gio/glocalfile.c
index d3d68eca9..51a94e51c 100644
--- a/gio/glocalfile.c
+++ b/gio/glocalfile.c
@@ -2068,6 +2068,7 @@ g_local_file_trash (GFile         *file,
          (global_stat.st_mode & S_ISVTX) != 0)
        {
          trashdir = g_build_filename (globaldir, uid_str, NULL);
+         success = TRUE;
 
          if (g_lstat (trashdir, &trash_stat) == 0)
            {
@@ -2077,12 +2078,14 @@ g_local_file_trash (GFile         *file,
                  /* Not a directory or not owned by user, ignore */
                  g_free (trashdir);
                  trashdir = NULL;
+                 success = FALSE;
                }
            }
          else if (g_mkdir (trashdir, 0700) == -1)
            {
              g_free (trashdir);
              trashdir = NULL;
+             success = FALSE;
            }
        }
       g_free (globaldir);


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