GNOME Bugzilla – Bug 617630
XDG_DOWNLOAD_DIR=$HOME not respected
Last modified: 2013-02-21 10:50:50 UTC
Hello I'was happy to find that the special directory lookup (and create if inexistant) code was recently improved to respect XDG_ directorys set in ~/.config/user-dirs.dirs Now I'm disappointed again after finding out that a ~/Downloads directory is still created in my home dir, because my XDG_DOWNLOAD_DIR is the same as my home dir (Or is there anything wrong with that ? - I like it that way because this is where i see the files and clean them up or put in the appropriate folder. I don't want a Downloads dir, where I don't see the files and they get piled up ... anyways ... everybody to his likings.) So what is that check in http://git.gnome.org./browse/gnome-user-share/tree/src/user_share-common.c#n36 "strcmp (special_dir, g_get_home_dir ()) != 0" actually good for? The code there (until the end of the function) translates to: "If the requested special directory is the same as the users home directory, ignore the users preference and use [users home directory]/[nameof special directory] instead." Can you (the author) explain to me, why it should be ignored it in that case?
We don't want to download directly in the home directory, nor do we want to share the home directory. It's a (mild) security decision. For your particular case, $HOME would usually end up being the download directory when a Downloads directory wasn't set up at all, which is why it doesn't work when you try to override it. g_get_user_special_dir() will return $HOME if xdg-user-dirs aren't setup, thus we don't have any other ways to detect failure.
Created attachment 160256 [details] g_get_user_special_dir () -- Returns: the path to the specified special directory, or NULL if the logical id was not found. http://library.gnome.org/devel/glib/stable/glib-Miscellaneous-Utility-Functions.html
Well, that would be a reasonable explanation if your assumption about g_get_user_special_dir() returning $HOME, if the directory is not set, was true. But, on my system at least as well as in theory, it's not: Theory: http://library.gnome.org/devel/glib/stable/glib-Miscellaneous-Utility-Functions.html#g-get-user-special-dir Praxis: ---------------------------------------------------------------------------- pat@babar:~$ bash test.sh G_USER_DIRECTORY_DOWNLOAD is /home/pat `/home/pat/.config/user-dirs.dirs' -> `/home/pat/.config/user-dirs.dirs~' G_USER_DIRECTORY_DOWNLOAD is NULL `/home/pat/.config/user-dirs.dirs~' -> `/home/pat/.config/user-dirs.dirs' ---------------------------------------------------------------------------- Removing .config/user-dirs.dirs and then running xdg-user-dirs-update or xdg-user-dirs-update sets them as follows (on my system (~ ubuntu karmic)): ---------------------------------------------------------------------------- XDG_DESKTOP_DIR="$HOME/Desktop" XDG_DOWNLOAD_DIR="$HOME/Downloads" XDG_TEMPLATES_DIR="$HOME/Templates" XDG_PUBLICSHARE_DIR="$HOME/Public" XDG_DOCUMENTS_DIR="$HOME/Documents" XDG_MUSIC_DIR="$HOME/Music" XDG_PICTURES_DIR="$HOME/Pictures" XDG_VIDEOS_DIR="$HOME/Videos" --------------------------------------------------------------------------- So in the end, what I'm trying to say is: please let me keep my XDG_DOWNLOAD_DIR="$HOME" (its my choice, I'm taking the risk). I think nobody will get hurt if you remove that second test on 36 in user_share-common.c. Or are there other arguments are there against it?
edt: "or xdg-user-dirs-update" -> "or xdg-user-dirs-gtk-update"
Sorry. Where did you get the information that "g_get_user_special_dir() will return $HOME if xdg-user-dirs aren't setup" from then ? Do you think that there might be cases where it's valid ? Cheers
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find. *** This bug has been marked as a duplicate of bug 639258 ***