Changeset 49 for LATMOS-Accounts/lib/LATMOS/Accounts/Synchro.pm
- Timestamp:
- 04/25/09 21:18:18 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
LATMOS-Accounts/lib/LATMOS/Accounts/Synchro.pm
r45 r49 30 30 our $VERSION = (q$Rev$ =~ /^Rev: (\d+) /)[0]; 31 31 32 =head2 new($from, $to )32 =head2 new($from, $to, %options) 33 33 34 34 Create a new synchronisation where $from and $to are LATMOS::Accounts::Base … … 38 38 39 39 sub new { 40 my ($class, $from, $to ) = @_;40 my ($class, $from, $to, %options) = @_; 41 41 42 my $self = {}; 42 if ($options{state_file} && ! -w $options{state_file}) { 43 # don't exists, we have to create it 44 open(my $handle, '>', $options{state_file}) or return; 45 close($handle); 46 } 43 47 48 my $self = Config::IniFiles->new( 49 $options{state_file} 50 ? (-file => $options{state_file}) 51 : (), 52 ); 53 54 44 55 $self->{from} = $from; 45 56 … … 105 116 $self->load_dest and return; 106 117 118 # tracking current base revision: 119 my $current_rev = $self->from->current_rev; 120 107 121 # listing existing obj one time: 108 122 foreach my $otype ($self->from->list_supported_objects) { … … 115 129 # loading object list one time for all 116 130 # TODO optimize this, using rev of objects 117 my @lobjfrom = $self->from->list_objects($otype);118 131 119 132 warn "Sync objects $otype\n"; 120 133 foreach my $destbase (@obj_dest_base) { 134 my @lobjfrom = $self->from->list_objects_from_rev( 135 $otype, 136 $self->val($self->from->label, $destbase->label), 137 ); 121 138 warn "objects $otype => " . $destbase->type . "\n"; 122 139 my @common_fields = $self->_common_fields($self->from, $destbase, $otype); … … 141 158 142 159 foreach ($self->to) { 143 $_->commit; 160 $_->commit or next; 161 $self->newval($self->from->label, $_->label, $current_rev) if($current_rev); 144 162 } 145 163 164 $self->RewriteConfig if($self->GetFileName); 165 146 166 1; 147 167 }
Note: See TracChangeset
for help on using the changeset viewer.