diff options
Diffstat (limited to 'imapsync')
-rwxr-xr-x | imapsync | 21 |
1 files changed, 8 insertions, 13 deletions
@@ -93,13 +93,13 @@ my $DBH; # Clean after us sub cleanup() { - logger("Cleaning up...") if $CONFIG{debug}; + logger(undef, "Cleaning up...") if $CONFIG{debug}; unlink $LOCKFILE if defined $LOCKFILE and -f $LOCKFILE; close $LOGGER_FD if defined $LOGGER_FD; $DBH->disconnect() if defined $DBH; } -$SIG{$_} = sub { cleanup(); msg(undef, $!); exit 1; } foreach qw/INT TERM/; -$SIG{$_} = sub { cleanup(); msg(undef, $!); exit 0; } foreach qw/HUP/; +$SIG{$_} = sub { msg(undef, $!); cleanup(); exit 1; } foreach qw/INT TERM/; +$SIG{$_} = sub { msg(undef, $!); cleanup(); exit 0; } foreach qw/HUP/; ############################################################################# @@ -627,7 +627,7 @@ sub download_missing($$$@) { # Solve a flag update conflict (by taking the union of the two flag lists). sub flag_conflict($$$$$) { - my ($mailbox, $lUID, $lFlags, $rUID, $rFlags); + my ($mailbox, $lUID, $lFlags, $rUID, $rFlags) = @_; my %flags = map {$_ => 1} (split(/ /, $lFlags), split(/ /, $rFlags)); my $flags = join ' ', sort(keys %flags); @@ -947,7 +947,8 @@ sub callback_new_message_flush($$$@) { my ($lUIDs, $rUIDs) = $name eq 'local' ? (\@sUID,\@tUID) : (\@tUID,\@sUID); for (my $k=0; $k<=$#messages; $k++) { - logger("Adding mapping (lUID,rUID) = ($lUIDs->[$k],$rUIDs->[$k]) for $mailbox") if $CONFIG{debug}; + logger(undef, "Adding mapping (lUID,rUID) = ($lUIDs->[$k],$rUIDs->[$k]) for $mailbox") + if $CONFIG{debug}; $STH_INSERT_MAPPING->execute($idx, $lUIDs->[$k], $rUIDs->[$k]); } $DBH->commit(); # commit only once per batch @@ -1102,10 +1103,7 @@ while (@REPAIR) { $rIMAP->select($MAILBOX); repair($IDX, $MAILBOX); } -if ($CONFIG{repair}) { - cleanup(); - exit 0; -} +exit 0 if $CONFIG{repair}; while(1) { @@ -1153,10 +1151,7 @@ while(1) { } } # clean state! - if ($CONFIG{oneshot}) { - cleanup(); - exit 0; - } + exit 0 if $CONFIG{oneshot}; wait_notifications(900); } |