From 14e5d6b258c79b5982aafb804fdeeac35a21598c Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sun, 26 Jul 2015 06:56:04 +0200 Subject: Check return value after a SQL UPDATE. --- imapsync | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/imapsync b/imapsync index fec37f0..41e3538 100755 --- a/imapsync +++ b/imapsync @@ -337,7 +337,8 @@ sub sync_tree($$%) { # $missing's $mbx2, which is not in the database and # doesn't exist on $exists msg($exists, "Rename mailbox $mbx to $mbx2[0]"); - $sth->{rename}->execute($mbx2[0],$idx); + $sth->{rename}->execute($mbx2[0],$idx) or + msg('database', "WARNING: Can't rename $mbx to $mbx2[0]"); $IMAP->{$exists}->{client}->rename($mbx, $mbx2[0]); $DBH->commit(); mv_tree($IMAP->{$exists}->{mailboxes}, $mbx, $mbx2[0], %children); @@ -375,7 +376,8 @@ sub sync_tree($$%) { # database as associated with $mbx2, which exists on # $missing but not on $exists msg($missing, "Rename mailbox $mbx2 to $mbx"); - $sth->{rename}->execute($mbx,$idx); + $sth->{rename}->execute($mbx,$idx) or + msg('database', "WARNING: Can't rename $mbx2 to $mbx2"); $IMAP->{$missing}->{client}->rename($mbx2, $mbx); $DBH->commit(); mv_tree($IMAP->{$missing}->{mailboxes}, $mbx2, $mbx, %children); @@ -992,8 +994,10 @@ sub sync_messages($$;$$) { # don't store the new UIDNEXTs before to avoid downloading these # mails again in the event of a crash - $STH_UPDATE_LOCAL->execute($lIMAP->get_cache( qw/UIDNEXT HIGHESTMODSEQ/), $idx); - $STH_UPDATE_REMOTE->execute($rIMAP->get_cache(qw/UIDNEXT HIGHESTMODSEQ/), $idx); + $STH_UPDATE_LOCAL->execute($lIMAP->get_cache( qw/UIDNEXT HIGHESTMODSEQ/), $idx) or + msg('database', "WARNING: Can't update remote UIDNEXT/HIGHESTMODSEQ for $mailbox"); + $STH_UPDATE_REMOTE->execute($rIMAP->get_cache(qw/UIDNEXT HIGHESTMODSEQ/), $idx) or + msg('database', "WARNING: Can't update remote UIDNEXT/HIGHESTMODSEQ for $mailbox"); $DBH->commit(); } @@ -1139,8 +1143,10 @@ while(1) { elsif (sync_known_messages($IDX, $MAILBOX)) { # sync updates to known messages before fetching new messages # get_cache is safe after pull_update - $STH_UPDATE_LOCAL_HIGHESTMODSEQ->execute( $lIMAP->get_cache('HIGHESTMODSEQ'), $IDX); - $STH_UPDATE_REMOTE_HIGHESTMODSEQ->execute($rIMAP->get_cache('HIGHESTMODSEQ'), $IDX); + $STH_UPDATE_LOCAL_HIGHESTMODSEQ->execute( $lIMAP->get_cache('HIGHESTMODSEQ'), $IDX) and + msg('database', "WARNING: Can't update local HIGHESTMODSEQ for $MAILBOX"); + $STH_UPDATE_REMOTE_HIGHESTMODSEQ->execute($rIMAP->get_cache('HIGHESTMODSEQ'), $IDX) or + msg('database', "WARNING: Can't update remote HIGHESTMODSEQ for $MAILBOX"); $DBH->commit(); } sync_messages($IDX, $MAILBOX); -- cgit v1.2.3