Ignore:
Timestamp:
12/27/12 18:26:32 (12 years ago)
Author:
nanardon
Message:

add tools to reset (bug #3)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/SyncManager.pm

    r1200 r1201  
    190190} 
    191191 
     192=head2 reset_module_checkpoint($module) 
     193 
     194Reset the checkpoint for module C<$module> to force it to run at next 
     195synchronisation. 
     196 
     197=cut 
     198 
     199sub reset_module_checkpoint { 
     200    my ($self, $module) = @_; 
     201    if (!$self->ini->SectionExists($module)) { 
     202        la_log LA_ERR, "Cannot run inexistant module %s", $module; 
     203        return; 
     204    } 
     205 
     206    my $modtype = $self->ini->val($module, 'type', $module); 
     207    my $task = LATMOS::Accounts::Task->new( 
     208        $modtype, 
     209        config => $self->{config}, 
     210        name   => $module, 
     211        syncm  => $self, 
     212    ) 
     213        or do { 
     214        la_log(LA_ERR, 'Cannot load module %s', $modtype); 
     215        return; 
     216    }; 
     217    $task->init or do { 
     218        la_log LA_ERR, "Cannot init module %s", $_; 
     219        return; 
     220    }; 
     221 
     222    my $ini = $self->_load_state_ini or return; 
     223 
     224    $ini->delval($module, 'rev'); 
     225    $ini->newval($module, 'time', 0); 
     226    $ini->SetParameterComment( 
     227        $module, 'time', 
     228        'Reset to 0 the ' . scalar(localtime(time)), 
     229    ); 
     230 
     231    $task->reset_checkpoint; # Specific reset 
     232    $ini->RewriteConfig; 
     233} 
     234 
    1922351; 
    193236 
Note: See TracChangeset for help on using the changeset viewer.