Ignore:
Timestamp:
Jul 4, 2009, 12:09:47 AM (15 years ago)
Author:
ronosman
Message:

Bug 1030 fixed : catch communication error with Piwigo site. The Piwigo method return status is checked after checking HTTP response status.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/pLoader/trunk/src/Uploader/ImageList.pm

    r3472 r3509  
    3131use Encode qw/encode decode is_utf8/;
    3232use Wx::Locale qw/:default/;
     33use Wx;
    3334
    3435# this class implements a collection of image files with associated data
     
    6970                SetNewFilesProgressCallback
    7071                SetNewFilesDisplayEndInfoCallback
     72                YieldCallback
    7173                UploadImagesViewerCallback
    7274                progress_thumbnail_refresh
     
    883885   
    884886            # update upload progress dialog
    885             $self->progressbar_refresh->(0.20);
     887            $self->progressbar_refresh->(0.05);
    886888        };
    887889        # user cancelled : dialog box is destroyed
     
    929931        }
    930932
     933        # Resized and original are ready
     934        $self->progressbar_refresh->(0.10);
     935
     936
    931937        $msg = sprintf(
    932938            "Preparing thumbnail for %s - %s",
     
    960966        eval {
    961967            $self->progress_msg_refresh->($msg);
    962             $self->progressbar_refresh->(0.50);
     968            # Thumbnail is ready
     969            $self->progressbar_refresh->(0.20);
    963970        };
    964971        croak "Upload cancelled. ", $@ if $@ ;
     
    966973        # photo metadata
    967974        $self->_prepare_upload_properties();           
    968         my ( $status, $status_msg ) = $self->pwg->UploadImage();
    969 
     975        my ( $status, $status_msg, $content ) = $self->pwg->UploadImage( $self->YieldCallback, $self->progressbar_refresh );
     976        my $ok = 0;
     977        # HTTP REQUEST OK
    970978        if ( $status ){
     979            # PIWIGO RESULT ( HTTP may be ok while Piwigo is not )
     980            $ok = 'fail' eq $content->{stat} ? 0 : 1;
     981        }
     982        else{
     983            Wx::LogMessage(
     984                "% %s : %s",
     985                gettext("Communication error with"),
     986                $self->pwg->site_url,
     987                $status_msg,
     988            );
     989        }
     990
     991        if($ok){
    971992            $msg = sprintf(
    972                 "%s : %s upload succcessful.",
     993                "%s : %s - %s.",
    973994                $site_name,
    974                 $file
     995                $file,
     996                gettext("upload succcessful"),
    975997            );
    976998
     
    9791001        } else {
    9801002            $msg = sprintf(
    981                 "An error has occured.\n%s : %s upload is cancelled.\n$status_msg",
     1003                "An error has occured.\n%s : %s upload is cancelled.\n%s",
    9821004                $site_name,
    983                 $file
     1005                $file,
     1006                Dumper($content),
    9841007            );
    9851008            $rejected++;
     
    10091032    my $duration = $time_end - $time_begin;
    10101033    $msg = sprintf(
    1011         "%s images processed\n\n%s images uploaded\n\n%s images in errors and not uploaded - $last_error\n\nDuration : %s seconds",
     1034        "%s images processed\n\n%s images uploaded\n\n%s images in errors and not uploaded - \n%s\n\nDuration : %s seconds",
    10121035        $self->count - 1,
    10131036        $uploaded,
    10141037        $rejected,
     1038        $last_error,
    10151039        $duration,
    10161040    );
Note: See TracChangeset for help on using the changeset viewer.