Ignore:
Timestamp:
Dec 10, 2009, 3:21:06 PM (14 years ago)
Author:
ronosman
Message:

Feature 1052 added : photo re-upload management. When uploading an already added photo, the user is warned and has a choice on action for files, simple properties and multi-values properties.

File:
1 edited

Legend:

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

    r4422 r4467  
    9595                use_exif_preview
    9696                image_sums
     97                                upload_image_sums
    9798                sums
    9899                version
     
    120121                upload_file
    121122                upload_name
     123                                ReuploadCallback
     124                                reupload_action_files
     125                                reupload_action_properties
     126                                reupload_action_properties_m
     127                                reupload_not_ask
    122128     /
    123129);
     
    253259            # ok
    254260            if(!$@){
    255                 $self->progress_msg("Selection thumbnail created for %s");
     261                $self->progress_msg(gettext("Selection thumbnail created for %s"));
    256262            }
    257263            else {
     
    554560   
    555561    my $rval = 1 ;
    556     return $rval if( -e $self->current_image->site_resized_file );
     562    #return $rval if( -e $self->current_image->site_resized_file );
    557563
    558564    printf(
     
    634640    my ( $self ) = @_;
    635641   
    636     return 1 if( -e $self->current_image->site_thumb_file );
     642    #return 1 if( -e $self->current_image->site_thumb_file );
    637643   
    638644    my $rval = 1;
     
    765771                watermark_x
    766772                watermark_color
     773                                reupload_action_files
     774                                reupload_action_properties
     775                                reupload_action_properties_m
    767776            /
    768777        ]
     
    797806    $self->upload_begin_time(time);
    798807    $self->upload_selection_count(scalar @{$self->image_selection});
     808        # for re-upload management
     809    $self->upload_image_sums( [
     810                map { $self->GetImage($_)->file_sum }
     811                    @{$self->image_selection}
     812            ]
     813        );
     814
     815        # check if already exist on server
     816        my $uploaded = $self->pwg->IsAlreadyUploaded($self->upload_image_sums);
     817        my @already_uploaded = grep { $_ } values %$uploaded ;
     818        $self->ReuploadCallback->() if ( scalar @already_uploaded and !$self->reupload_not_ask );
     819
     820       
    799821    foreach(@{$self->image_selection}) {
    800         # current image object         
     822        # current image object         
    801823        $self->current_image(
    802824            $self->GetImage($_)
    803         );
     825        ); 
    804826        # prepare resized, high, thumbnail
    805         $self->_upload_selection_prepare();
     827                # if not already uploaded
     828        $self->_set_site_resized_file();
     829        $self-> _set_site_high_file ();
     830        # photo metadata
     831        $self->_prepare_upload_properties();           
     832        $self->_upload_selection_prepare() if (!$uploaded->{$self->current_image->file_sum} or $self->reupload_action_files);
    806833
    807834        # transfert resized, high, thumbnail to site
     
    827854    $self->progress_thumbnail_refresh->();
    828855    # PREPARE
    829     $self->_set_site_resized_file();
    830856    $self->_set_upload_msg(gettext("Preparing resized image for"));
    831857    $self->_upload_progress();
     
    848874            'Yes, use a copy of the original photo' => 'ORIGINAL',
    849875    }; 
    850 
     876printf("upload HD %s\n", $self->upload_hd);
    851877        $self->upload_high(
    852878            $decode->{$self->upload_hd}
     
    866892    $self->_upload_progress();
    867893
    868     # photo metadata
    869     $self->_prepare_upload_properties();       
    870894
    871895}
     
    923947            highdef_msg=>gettext("Uploading high definition"),
    924948            checksum_msg=>gettext("Checksum for"),
     949            original_sum=>$self->current_image->file_sum,
    925950        }
    926951    );
     
    11021127
    11031128    if($bModifyOriginal){
    1104         $self-> _set_site_high_file ();
    11051129
    11061130        my $image = Image::Magick->new();
     
    12381262sub _prepare_upload_properties {
    12391263    my ( $self ) = @_;
     1264
     1265        $self->pwg->reupload_action_files(
     1266            $self->reupload_action_files||1
     1267        );
     1268        $self->pwg->reupload_action_properties(
     1269            $self->reupload_action_properties||2
     1270        );
     1271
     1272        $self->pwg->reupload_action_properties_m(
     1273            $self->reupload_action_properties_m||1
     1274        );
    12401275   
    12411276    $self->pwg->upload_high(
     
    12851320        join(',', @{$self->current_image->site_tags})
    12861321    );
     1322
    12871323       
    12881324}
Note: See TracChangeset for help on using the changeset viewer.