After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 617630 - XDG_DOWNLOAD_DIR=$HOME not respected
XDG_DOWNLOAD_DIR=$HOME not respected
Status: RESOLVED DUPLICATE of bug 639258
Product: gnome-user-share
Classification: Core
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gnome-user-share maintainers
gnome-user-share maintainers
Depends on:
Blocks:
 
 
Reported: 2010-05-04 10:35 UTC by patrick
Modified: 2013-02-21 10:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
g_get_user_special_dir () -- Returns: the path to the specified special directory, or NULL if the logical id was not found. (418 bytes, application/x-sh)
2010-05-04 12:45 UTC, patrick
Details

Description patrick 2010-05-04 10:35:29 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?
Comment 1 Bastien Nocera 2010-05-04 11:38:11 UTC
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.
Comment 2 patrick 2010-05-04 12:45:08 UTC
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
Comment 3 patrick 2010-05-04 12:45:40 UTC
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?
Comment 4 patrick 2010-05-04 12:49:31 UTC
edt: "or xdg-user-dirs-update" -> "or xdg-user-dirs-gtk-update"
Comment 5 patrick 2010-05-11 07:03:28 UTC
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
Comment 6 Bastien Nocera 2013-02-21 10:50:50 UTC
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 ***