Changeset 861 for LATMOS-Accounts/lib/LATMOS/Accounts/Synchro.pm
- Timestamp:
- 12/02/11 11:42:17 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
LATMOS-Accounts/lib/LATMOS/Accounts/Synchro.pm
r819 r861 124 124 $self->load_dest and return; 125 125 my %state = (); 126 $state{$self->from->label} = $self->from->wexported(0); 126 $state{$self->from->label} = $self->from->wexported( 127 $self->{options}{unexported} ? 1 : 0 128 ); 127 129 foreach ($self->to) { 128 130 $state{$_->label} = $_->wexported(1); … … 137 139 la_log(LA_DEBUG, "Leaving synch mode"); 138 140 $self->from->wexported($state{$self->from->label}); 139 foreach ($self->to) {140 $ _->commit;141 $ _->wexported($state{$_->label});141 foreach my $base (grep { $_ } $self->to) { 142 $base->commit; 143 $base->wexported($state{$base->label}); 142 144 } 143 145 } … … 205 207 206 208 $self->lock or return; 209 210 if (!(my $res = $self->run_pre_synchro({}))) { 211 la_log(LA_ERR, "Pre synchro script failed, aborting"); 212 $self->unlock; 213 return; 214 } 207 215 208 216 my %state = $self->enter_synch_mode; … … 230 238 $self->from->label, $otype, $_, $destbase->label, $res, 231 239 ); 240 if ($destbase->is_transactionnal) { 241 $destbase->commit; 242 } 232 243 $updated = 1; 244 } else { 245 if ($destbase->is_transactionnal) { 246 $destbase->rollback; 247 } 233 248 } 234 249 } … … 241 256 } 242 257 foreach my $pass (1, 0) { 243 foreach my $otype ( 244 sort { $a eq 'user' ? 1 : -1 } # user in last because gidNumber needed 245 keys %objlist) { 246 next if (!$pass && !$destbase->delayed_fields($otype)); 258 foreach my $otype ($destbase->ordered_objects) { 259 exists($objlist{$otype}) or next; 247 260 foreach (@{$objlist{$otype} || []}) { 248 261 my $res = $destbase->sync_object_from($self->from, $otype, $_, … … 254 267 $destbase->label, $res, 255 268 ); 269 if ($destbase->is_transactionnal) { 270 $destbase->commit; 271 } 256 272 $updated = 1; 257 273 } … … 262 278 ); 263 279 $desterror{$destbase->label} = 1; 280 if ($destbase->is_transactionnal) { 281 $destbase->rollback; 282 } 264 283 } 265 284 … … 272 291 my $res = $self->run_post_synchro( 273 292 { 274 UPDATED => $updated ,293 UPDATED => $updated || undef, 275 294 } 276 295 ); … … 313 332 } 314 333 334 sub run_pre_synchro { 335 my ($self, $env) = @_; 336 337 $env ||= {}; 338 $env->{HOOK_TYPE} = 'PRE'; 339 340 foreach my $base ($self->to) { 341 if ($base->options('presynchro')) { 342 la_log LA_DEBUG, "Executing base pre synchro `%s' for %s", 343 $base->options('presynchro'), $base->label; 344 exec_command( 345 $base->options('presynchro'), 346 { 347 BASE => $base->label, 348 BASETYPE => $base->type, 349 %{ $env }, 350 } 351 ); 352 } 353 } 354 355 $self->{options}{pre} or return 1; 356 357 la_log(LA_DEBUG, "Running post synchro `%s'", $self->{options}{pre}); 358 359 exec_command($self->{options}{post}, $env); 360 } 361 315 362 sub run_post_synchro { 316 363 my ($self, $env) = @_; 364 365 $env ||= {}; 366 $env->{HOOK_TYPE} = 'PRE'; 367 368 foreach my $base ($self->to) { 369 if ($base->options('postsynchro')) { 370 la_log LA_DEBUG, "Executing base post synchro `%s' for %s", 371 $base->options('postsynchro'), $base->label; 372 exec_command( 373 $base->options('postsynchro'), 374 { 375 BASE => $base->label, 376 BASETYPE => $base->type, 377 %{ $env }, 378 } 379 ); 380 } 381 } 317 382 318 383 $self->{options}{post} or return 1; 319 384 320 la_log(LA_ INFO, "Running post synchro `%s'", $self->{options}{post});321 385 la_log(LA_DEBUG, "Running post synchro `%s'", $self->{options}{post}); 386 322 387 exec_command($self->{options}{post}, $env); 323 388 }
Note: See TracChangeset
for help on using the changeset viewer.