Changeset 819


Ignore:
Timestamp:
03/10/10 00:40:38 (14 years ago)
Author:
nanardon
Message:
  • set LA_UPDATED env. var. when running post script: indicate if data were updated, the script can skip useless work so
  • take into account script error code if any, then assume there were an error
Location:
LATMOS-Accounts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • LATMOS-Accounts/Makefile.PL

    r816 r819  
    55WriteMakefile( 
    66    NAME              => 'LATMOS::Accounts', 
    7     VERSION           => '0.0.19', # finds $VERSION 
     7    VERSION           => '0.0.20', # finds $VERSION 
    88    PREREQ_PM         => { 
    99        'Net::LDAP' => undef, 
  • LATMOS-Accounts/lib/LATMOS/Accounts/Synchro.pm

    r815 r819  
    141141        $_->wexported($state{$_->label}); 
    142142    } 
    143     $self->run_post_synchro; 
    144143} 
    145144 
     
    214213    my %desterror; 
    215214    my %existings; 
     215    my $updated = 0; 
    216216    foreach my $destbase ($self->to) { 
    217217        my %objlist; 
     
    225225            foreach ($destbase->list_objects($otype)) { 
    226226                if(!$existings{$otype}{$_}) { 
    227                     my $res = $destbase->sync_object_from($self->from, $otype, $_, %options); 
    228                     la_log(LA_NOTICE, "%s::%s::%s => %s %s", 
    229                         $self->from->label, $otype, $_, $destbase->label, $res, 
    230                     ) if ($res); 
     227                    if (my $res = $destbase->sync_object_from($self->from, 
     228                            $otype, $_, %options)) { 
     229                        la_log(LA_NOTICE, "%s::%s::%s => %s %s", 
     230                            $self->from->label, $otype, $_, $destbase->label, $res, 
     231                        ); 
     232                        $updated = 1; 
     233                    } 
    231234                } 
    232235            } 
     
    246249                        %options, firstpass => $pass); 
    247250                    if (defined $res) { 
    248                         la_log(LA_NOTICE, "%s::%s::%s => %s %s", 
    249                             $self->from->label, $otype, $_, 
    250                             $destbase->label, $res, 
    251                         ) if ($res); 
     251                        if ($res) { 
     252                            la_log(LA_NOTICE, "%s::%s::%s => %s %s", 
     253                                $self->from->label, $otype, $_, 
     254                                $destbase->label, $res, 
     255                            ); 
     256                            $updated = 1; 
     257                        } 
    252258                    } else { 
    253259                        la_log(LA_ERR, "Cannot synch %s::%s::%s => %s", 
     
    264270 
    265271    $self->leave_synch_mode(%state); 
    266     foreach my $destbase ($self->to) { 
    267         # don't register checkpoint on error 
    268         if ($desterror{$destbase->label}) { next; } 
    269         $self->newval($self->from->label, $destbase->label, $self->{current_rev}); 
    270     } 
    271  
    272     if(!($self->{options}{nocreate} || 
    273             $self->{options}{test})) { 
    274         $self->write_status; 
     272    my $res = $self->run_post_synchro( 
     273        { 
     274            UPDATED => $updated, 
     275        } 
     276    ); 
     277    if ($res) { 
     278        foreach my $destbase ($self->to) { 
     279            # don't register checkpoint on error 
     280            if ($desterror{$destbase->label}) { next; } 
     281            $self->newval($self->from->label, $destbase->label, $self->{current_rev}); 
     282        } 
     283 
     284        if(!($self->{options}{nocreate} || 
     285                $self->{options}{test})) { 
     286            $self->write_status; 
     287        } 
     288    } else { 
     289        la_log(LA_ERROR, "Not updating status because post script failed"); 
    275290    } 
    276291 
     
    299314 
    300315sub run_post_synchro { 
    301     my ($self) = @_; 
     316    my ($self, $env) = @_; 
    302317 
    303318    $self->{options}{post} or return 1; 
     
    305320    la_log(LA_INFO, "Running post synchro `%s'", $self->{options}{post}); 
    306321 
    307     exec_command($self->{options}{post}, $self->{options}); 
     322    exec_command($self->{options}{post}, $env); 
    308323} 
    309324 
Note: See TracChangeset for help on using the changeset viewer.