]> granicus.if.org Git - transmission/commitdiff
(trunk libT) better version of r8775
authorCharles Kerr <charles@transmissionbt.com>
Fri, 3 Jul 2009 14:37:27 +0000 (14:37 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Fri, 3 Jul 2009 14:37:27 +0000 (14:37 +0000)
libtransmission/metainfo.c

index 380522eda300ebaf6f5cb172de9f4d63241cf165..3048f2f13dd416786751f69fcac57371fd2a99b1 100644 (file)
@@ -60,11 +60,12 @@ static char*
 getOldTorrentFilename( const tr_session * session, const tr_info * inf )
 {
     int i;
-    const char * tags[] = { "beos", "cli", "daemon", "gtk", "macosx", "wx" };
-    const int tagCount = 6;
     char * path;
     struct stat sb;
+    const int tagCount = 5;
+    const char * tags[] = { "beos", "cli", "daemon", "macosx", "wx" };
 
+    /* test the beos, cli, daemon, macosx, wx tags */
     for( i=0; i<tagCount; ++i ) {
         path = tr_strdup_printf( "%s%c%s-%s", tr_getTorrentDir( session ), '/', inf->hashString, tags[i] );
         if( !stat( path, &sb ) && ( ( sb.st_mode & S_IFMT ) == S_IFREG ) )
@@ -72,12 +73,16 @@ getOldTorrentFilename( const tr_session * session, const tr_info * inf )
         tr_free( path );
     }
 
+    /* test a non-tagged file */
     path = tr_buildPath( tr_getTorrentDir( session ), inf->hashString, NULL );
     if( !stat( path, &sb ) && ( ( sb.st_mode & S_IFMT ) == S_IFREG ) )
         return path;
     tr_free( path );
 
-    return NULL;
+    /* return the -gtk form by default, since that's the most common case.
+       don't bother testing stat() on it since this is the last candidate
+       and we don't want to return NULL anyway */
+    return tr_strdup_printf( "%s%c%s-%s", tr_getTorrentDir( session ), '/', inf->hashString, "gtk" );
 }
 
 /* this is for really old versions of T and will probably be removed someday */