mirror of
https://github.com/transmission/transmission
synced 2025-02-20 21:26:53 +00:00
(gtk) #1409: "Duplicate Torrent" error message should be more helpful
This commit is contained in:
parent
3bc08c53f0
commit
63441d981d
2 changed files with 49 additions and 32 deletions
20
gtk/main.c
20
gtk/main.c
|
@ -947,8 +947,13 @@ flushAddTorrentErrors( GtkWindow * window,
|
|||
GSList * l;
|
||||
GtkWidget * w;
|
||||
|
||||
for( l = *files; l; l = l->next )
|
||||
g_string_append_printf( s, "%s\n", (const char*)l->data );
|
||||
if( g_slist_length( *files ) > 1 ) {
|
||||
for( l=*files; l!=NULL; l=l->next )
|
||||
g_string_append_printf( s, "\xE2\x88\x99 %s\n", (const char*)l->data );
|
||||
} else {
|
||||
for( l=*files; l!=NULL; l=l->next )
|
||||
g_string_append_printf( s, "%s\n", (const char*)l->data );
|
||||
}
|
||||
w = gtk_message_dialog_new( window,
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
|
@ -972,15 +977,15 @@ showTorrentErrors( struct cbdata * cbdata )
|
|||
if( cbdata->errqueue )
|
||||
flushAddTorrentErrors( GTK_WINDOW( cbdata->wind ),
|
||||
ngettext( "Couldn't add corrupt torrent",
|
||||
"Couldn't add corrupt torrents",
|
||||
g_slist_length( cbdata->errqueue ) ),
|
||||
"Couldn't add corrupt torrents",
|
||||
g_slist_length( cbdata->errqueue ) ),
|
||||
&cbdata->errqueue );
|
||||
|
||||
if( cbdata->dupqueue )
|
||||
flushAddTorrentErrors( GTK_WINDOW( cbdata->wind ),
|
||||
ngettext( "Couldn't add duplicate torrent",
|
||||
"Couldn't add duplicate torrents",
|
||||
g_slist_length( cbdata->dupqueue ) ),
|
||||
"Couldn't add duplicate torrents",
|
||||
g_slist_length( cbdata->dupqueue ) ),
|
||||
&cbdata->dupqueue );
|
||||
}
|
||||
|
||||
|
@ -1000,8 +1005,7 @@ coreerr( TrCore * core UNUSED,
|
|||
break;
|
||||
|
||||
case TR_EDUPLICATE:
|
||||
c->dupqueue =
|
||||
g_slist_append( c->dupqueue, g_path_get_basename( msg ) );
|
||||
c->dupqueue = g_slist_append( c->dupqueue, g_strdup( msg ) );
|
||||
break;
|
||||
|
||||
case TR_CORE_ERR_NO_MORE_TORRENTS:
|
||||
|
|
|
@ -858,37 +858,50 @@ add_filename( TrCore * core,
|
|||
|
||||
if( filename && session )
|
||||
{
|
||||
int err;
|
||||
tr_ctor * ctor = tr_ctorNew( session );
|
||||
tr_ctor * ctor;
|
||||
|
||||
ctor = tr_ctorNew( session );
|
||||
tr_core_apply_defaults( ctor );
|
||||
tr_ctorSetPaused( ctor, TR_FORCE, !doStart );
|
||||
|
||||
if( tr_ctorSetMetainfoFromFile( ctor, filename ) )
|
||||
{
|
||||
tr_core_errsig( core, TR_EINVALID, filename );
|
||||
tr_ctorFree( ctor );
|
||||
}
|
||||
else if( ( err = tr_torrentParse( session, ctor, NULL ) ) )
|
||||
{
|
||||
/* don't complain about .torrent files in the watch directory
|
||||
that have already been added... that gets annoying, and we
|
||||
don't want to nag about cleaning up the watch dir */
|
||||
const gboolean quiet = ( err == TR_EDUPLICATE )
|
||||
&& ( core->priv->adding_from_watch_dir );
|
||||
if( !quiet )
|
||||
tr_core_errsig( core, err, filename );
|
||||
|
||||
tr_ctorFree( ctor );
|
||||
}
|
||||
else if( doPrompt )
|
||||
g_signal_emit( core, TR_CORE_GET_CLASS(
|
||||
core )->promptsig, 0, ctor );
|
||||
else
|
||||
{
|
||||
tr_torrent * tor = tr_torrentNew( session, ctor, &err );
|
||||
if( err )
|
||||
tr_core_errsig( core, err, filename );
|
||||
else
|
||||
tr_core_add_torrent( core, tr_torrent_new_preexisting( tor ) );
|
||||
tr_info inf;
|
||||
int err = tr_torrentParse( session, ctor, &inf );
|
||||
|
||||
switch( err )
|
||||
{
|
||||
case TR_EINVALID:
|
||||
tr_core_errsig( core, err, filename );
|
||||
break;
|
||||
|
||||
case TR_EDUPLICATE:
|
||||
/* don't complain about .torrent files in the watch directory
|
||||
* that have already been added... that gets annoying and we
|
||||
* don't want to be naggign users to clean up their watch dirs */
|
||||
if( !core->priv->adding_from_watch_dir )
|
||||
tr_core_errsig( core, err, inf.name );
|
||||
tr_metainfoFree( &inf );
|
||||
break;
|
||||
|
||||
default:
|
||||
if( doPrompt )
|
||||
g_signal_emit( core, TR_CORE_GET_CLASS( core )->promptsig, 0, ctor );
|
||||
else {
|
||||
tr_torrent * tor = tr_torrentNew( session, ctor, &err );
|
||||
if( err )
|
||||
tr_core_errsig( core, err, filename );
|
||||
else
|
||||
tr_core_add_torrent( core, tr_torrent_new_preexisting( tor ) );
|
||||
}
|
||||
tr_metainfoFree( &inf );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -900,8 +913,8 @@ tr_core_add_file( TrCore * core,
|
|||
GError ** err UNUSED )
|
||||
{
|
||||
add_filename( core, filename,
|
||||
pref_flag_get( PREF_KEY_START ),
|
||||
pref_flag_get( PREF_KEY_OPTIONS_PROMPT ) );
|
||||
pref_flag_get( PREF_KEY_START ),
|
||||
pref_flag_get( PREF_KEY_OPTIONS_PROMPT ) );
|
||||
*success = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue