transmission tries to use downloads folder but it doesnt exist

Bug #338046 reported by Duncan Hawthorne
6
Affects Status Importance Assigned to Milestone
Transmission
Fix Released
Unknown
transmission (Ubuntu)
Fix Released
Low
Chris Coulson

Bug Description

Binary package hint: transmission

starting transmission on a fresh user (or after wiped config)
open preferences, comes up with error:

The folder contents could not be displayed
Error stating file '/home/my-username/Downloads': No such file or directory
OK

the destination folder for downloads then switches to the home directory

$ lsb_release -rd
Description: Ubuntu jaunty (development branch)
Release: 9.04

$ apt-cache policy transmission
transmission:
  Installed: (none)
  Candidate: 1.51-0ubuntu1
  Version table:
     1.51-0ubuntu1 0
        500 http://archive.ubuntu.com jaunty/universe Packages

Revision history for this message
Charles Kerr (charlesk) wrote :

I don't know if we're going to do a 1.52 or not yet, but here's the patch against 1.51:

http://trac.transmissionbt.com/attachment/ticket/1773/startup.diff

Changed in transmission:
status: Unknown → Fix Released
Revision history for this message
Chris Coulson (chrisccoulson) wrote :

I'll package this later on today. Just a quick question about this bit of the patch though charles:

#ifdef HAVE_GIO
    str = NULL;
    if( !str ) str = g_get_user_special_dir( G_USER_DIRECTORY_DESKTOP );
    if( !str ) str = g_get_user_special_dir( G_USER_DIRECTORY_DOWNLOAD );
    if( !str ) str = tr_getDefaultDownloadDir( );
    pref_string_set_default ( PREF_KEY_DIR_WATCH, str );
    pref_flag_set_default ( PREF_KEY_DIR_WATCH_ENABLED, FALSE );
#endif

Shouldn't G_USER_DIRECTORY_DOWNLOAD take priority over G_USER_DIRECTORY_DESKTOP? It just so happens that both of these are set to ~/Desktop by default on Ubuntu, so will not matter to most people. However, I manually changed my XDG download directory to ~/Download, and would expect Transmission to choose this instead of my desktop when I first run it. The patch suggests that it will still choose my desktop as opposed to my download directory, unless I've misunderstood it.

Changed in transmission:
assignee: nobody → chrisccoulson
importance: Undecided → Low
status: New → In Progress
Revision history for this message
Charles Kerr (charlesk) wrote :

Hm, I think that's a good point. I agree that the two lines should be reversed to give G_USER_DIRECTORY_DOWNLOAD a higher priority.

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Thanks, I'll package the patch shortly with those 2 lines reversed.

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

charles, I've tested the patch and it fixes the original bug. One thing I've noticed though, is that the default download directory is always ~/Downloads, regardless of what XDG_DOWNLOAD_DIR is set too. This is because after the first time you call g_user_get_special_dir() to get the default watch directory, you clear the string returned by that, but that string is actually owned by glib and you can't clear it without messing up the internal glib data structure.

I'll incorporate a fix for that in this patch too.

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Hmmm, ok, that's not it. I'll keep looking at it, but you'll probably figure it out before me ;)

Revision history for this message
Charles Kerr (charlesk) wrote :

chris: I don't see where I'm misusing the return value of g_get_user_special_dir(). transmission calls it three times, all in tr_prefs_init_defaults(), and puts the return value in a const char* each time.

My guess is that the first time you run Transmission, it gets the g_get_user_special_dir(G_USER_DOWNLOAD_DIRECTORY) and stores it in ~/.config/transmission/settings.json, and reads it from there in subsequent sessions. So if you change XDG_DOWNLOAD_DIR *after* that first session, then there's some shear between settings.json and XDG_DOWNLOAD_DIR.

If that's what's going on, I'd agree that it's a little odd, but I wouldn't call it a bug -- the alternative would be to get rid of the configuration option and always defer to XDG_DOWNLOAD_DIR, but that would preclude users from having custom watch & download directories for torrents... which is something a large percentage of Transmission users do...

Revision history for this message
Charles Kerr (charlesk) wrote :

Hm, we could accomplish both if we had two options in the preferences:

[x] Use system default download directory
[ ] Use custom directory [ Directoryname | v ]

This feels like overkill to me. My (admittedly uninformed) guess is that most users won't ever know about XDG_DOWNLOAD_DIR or the dirs options in ~/.config/.

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

I think I should have explained a little better. If I start with a fresh user profile (after deleting ~/.config/transmission), then the default download directory always seems to be ~/Downloads on the first run (regardless of what I set XDG_DOWNLOAD_DIR to), whereas the watch directory is always configured correctly as XDG_DOWNLOAD_DIR.

I thought initially that the string returned from g_get_user_special_dir was being misused, but you are right - it is being used correctly. I still can't figure out what is going on though.

Revision history for this message
Duncan Hawthorne (duncan.hawthorne) wrote :

There is no need to have a seperate checkbox just for system default directory.
Simply set the entry for "custom directory" to be the system default directory by default, but allow it to be changed

Revision history for this message
Charles Kerr (charlesk) wrote :

@chris: I think this is fixed upstream now in <http://trac.transmissionbt.com/changeset/8048/>

Revision history for this message
Charles Kerr (charlesk) wrote :

upstream reference for the secondary issue: <http://trac.transmissionbt.com/ticket/1913>

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Thanks charles. I still see the same behaviour with the second patch though. I've done some debugging, and what seems to be happening is that the correct setting is overwritten later on after returning from tr_prefs_init_defaults. In tr_sessionLoadSettings, tr_sessionGetDefaultSettings is called which unconditionally overwrites the (correct) default download directory with the return value of tr_getDefaultDownloadDir (~/Downloads).

I commented out the call to tr_sessionGetDefaultSettings, rebuilt it, and it seems to work as expected.

Revision history for this message
Charles Kerr (charlesk) wrote :

Yes; changeset 8048 didn't pick up that change because I'm stupid and did "svn commit" in the gtk directory instead of the parent directory. The rest of the fix is in 8049.

If an unpatched 8049 doesn't do the trick for you, or I'm misunderstanding something, let me know.

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Thanks charles, I'll build and test that when I get home from work later.

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Thanks, that works ok now.

Changed in transmission:
status: In Progress → Triaged
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package transmission - 1.51-0ubuntu3

---------------
transmission (1.51-0ubuntu3) jaunty; urgency=low

  * 30_first-run-pref-error-fix.patch:
    - Don't show an error when the preferences dialog is opened
      for the first time (LP: #338046).
  * 31_honor-xdg_download_dir.patch:
    - Honor the users XDG_DOWNLOAD_DIR when running for the first time.

 -- Chris Coulson <email address hidden> Tue, 10 Mar 2009 23:35:43 +0000

Changed in transmission:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.