Changeset 2131


Ignore:
Timestamp:
Jun 17, 2007, 2:37:33 PM (15 years ago)
Author:
charles
Message:
  • if user aborts, don't physically create the torrent file. (thx BMW)
  • remove the gtk threading code that got checked in by accident in yesterday's flurry
  • slightly better error checking in makemeta
Location:
branches/file_selection
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/file_selection/gtk/main.c

    r2115 r2131  
    352352    textdomain( "transmission-gtk" );
    353353
    354     g_thread_init (0);
    355354    g_set_application_name( _("Transmission") );
    356355    gtk_init( argc, argv );
  • branches/file_selection/gtk/makemeta-ui.c

    r2124 r2131  
    8383        if( ui->builder->failed )
    8484        {
     85            const char * reason = ui->builder->abortFlag
     86                ? _("Torrent creation aborted.")
     87                : _("Torrent creation failed.");
    8588            w = gtk_message_dialog_new (GTK_WINDOW(ui->progress_dialog),
    8689                                        GTK_DIALOG_DESTROY_WITH_PARENT,
    8790                                        GTK_MESSAGE_ERROR,
    88                                         GTK_BUTTONS_CLOSE,
    89                                         _("Torrent creation failed.")); /* FIXME: tell why */
     91                                        GTK_BUTTONS_CLOSE, reason );
    9092            gtk_dialog_run( GTK_DIALOG( w ) );
    9193            gtk_widget_destroy( ui->progress_dialog );
     94            ui->builder->abortFlag = 0;
    9295        }
    9396        else
  • branches/file_selection/libtransmission/makemeta.c

    r2124 r2131  
    292292        memcpy( buf, prev, pch-prev );
    293293        buf[pch-prev] = '\0';
    294         /*fprintf ( stderr, "adding [%s] to the list of paths\n", buf );*/
    295294
    296295        sub = tr_bencListAdd( uninitialized_path );
     
    365364    int n = 5;
    366365    benc_val_t top, *val;
    367 fprintf( stderr, "builder %p in realMakeMetaInfo\n", builder );
    368366
    369367    tr_bencInit ( &top, TYPE_DICT );
     
    394392
    395393    /* save the file */
    396     if (1) {
     394    if ( !builder->abortFlag ) {
     395        size_t nmemb;
     396        char * pch = tr_bencSaveMalloc( &top, &n );
    397397        FILE * fp = fopen( builder->outputFile, "wb+" );
    398         char * pch = tr_bencSaveMalloc( &top, &n );
    399         fwrite( pch, n, 1, fp );
     398        nmemb = n;
     399        if( fp == NULL )
     400            builder->failed = 1;
     401        else if( fwrite( pch, 1, nmemb, fp ) != nmemb )
     402            builder->failed = 1;
    400403        free( pch );
    401404        fclose( fp );
     
    405408    tr_bencFree( & top );
    406409    builder->isDone = 1;
    407     builder->failed = builder->abortFlag; /* FIXME: doesn't catch all failures */
     410    builder->failed |= builder->abortFlag;
    408411}
    409412
     
    456459          break;
    457460
    458 fprintf( stderr, "worker thread got builder %p\n", builder);
    459461        tr_realMakeMetaInfo ( builder );
    460462    }
    461463
    462 fprintf( stderr, "worker thread exiting\n" );
    463464    workerIsRunning = 0;
    464465}
     
    483484    }
    484485
    485 fprintf( stderr, "enqueuing a builder %p\n", builder);
    486486    /* enqueue the builder */
    487487    lock = getQueueLock ( builder->handle );
     
    491491    if( !workerIsRunning ) {
    492492        workerIsRunning = 1;
    493 fprintf( stderr, "making new worker thread\n" );
    494493        tr_threadCreate( &workerThread, workerFunc, builder->handle, "makeMeta" );
    495494    }
  • branches/file_selection/libtransmission/utils.c

    r2107 r2131  
    330330tr_ioErrorFromErrno( void )
    331331{
    332     if( EACCES == errno || EROFS == errno )
    333     {
    334         return TR_ERROR_IO_PERMISSIONS;
    335     }
    336     else if( ENOSPC == errno )
    337     {
    338         return TR_ERROR_IO_SPACE;
    339     }
    340     else if( EMFILE == errno || EFBIG == errno )
    341     {
    342         return TR_ERROR_IO_RESOURCES;
    343     }
    344     tr_dbg( "generic i/o errno from errno: %s", strerror( errno ) );
    345     return TR_ERROR_IO_OTHER;
     332    switch( errno )
     333    {
     334        case EACCES:
     335        case EROFS:
     336            return TR_ERROR_IO_PERMISSIONS;
     337        case ENOSPC:
     338            return TR_ERROR_IO_SPACE;
     339        case EMFILE:
     340        case EFBIG:
     341            return TR_ERROR_IO_RESOURCES;
     342        default:
     343            tr_dbg( "generic i/o errno from errno: %s", strerror( errno ) );
     344            return TR_ERROR_IO_OTHER;
     345    }
    346346}
    347347
Note: See TracChangeset for help on using the changeset viewer.