# HG changeset patch # User Matthias Förste foerste@schlittermann.de # Date 1320831603 -3600 # Node ID 182b5c513e20509b8cae1f0b9ddd072361ee8f5b # Parent 7a2330a2d684e963db7c4bb60e6d28151d6e6182 deal with some possible nonfatal failures; more verbose results diff -r 7a2330a2d684 -r 182b5c513e20 isearch --- a/isearch Thu Nov 03 16:08:48 2011 +0100 +++ b/isearch Wed Nov 09 10:40:03 2011 +0100 @@ -86,8 +86,21 @@ for (@{$f}) { print "Examining $_ ...\n"; - $imap->examine($_) - or die "Can't examine: " . $imap->LastError . "\n"; + unless ($imap->examine($_)) { + + my $e = $imap->LastError; + # skip folder with invalid name + if ($e =~ /BAD Error in IMAP command EXAMINE: 8bit data in atom$/ + or $e =~ /NO Invalid mailbox name: /) { + warn "Can't examine '$_': $e\n"; + print "Skipping $_ ...\n"; + next; + } else { + die "Can't examine '$_': $e\n"; + } + + } + print "Searching $_ ...\n"; if ( my $m = $imap->search( $opts->{criteria} )) { $mids->{$_} = $m; @@ -100,11 +113,12 @@ # 2011-11-02 14:59:13 IMAP(userid): Error: Raw backtrace: imap [0x80f2fd1] -> imap [0x80f3052] -> imap [0x80f29a9] -> /usr/lib/dovecot/modules/imap/lib21_fts_squat_plugin.so [0xb744a50d] -> /usr/lib/dovecot/modules/imap/lib21_fts_squat_plugin.so(squat_trie_build_more+0x151) [0xb744a7a1] -> /usr/lib/dovecot/modules/imap/lib21_fts_squat_plugin.so [0xb7447a54] -> /usr/lib/dovecot/modules/imap/lib20_fts_plugin.so(fts_backend_build_more+0x2e) [0xb7453e7e] -> /usr/lib/dovecot/modules/imap/lib20_fts_plugin.so [0xb7456fb6] -> imap(mailbox_search_next_nonblock+0x2d) [0x80b6e7d] -> imap [0x806e221] -> imap(imap_search_start+0x150) [0x806e700] -> imap(cmd_search+0xff) [0x8064d2f] -> imap [0x8067c6c] -> imap [0x8067d09] -> imap(client_handle_input+0x2d) [0x8067e7d] -> imap(client_input+0x5f) [0x80687df] -> imap(io_loop_handler_run+0xe0) [0x80fbd80] -> imap(io_loop_run+0x20) [0x80fb1f0] -> imap(main+0x5ea) [0x80713ba] -> /lib/i686/cmov/libc.so.6(__libc_start_main+0xe5) [0xb75f1455] -> imap [0x8060351] # 2011-11-02 14:59:13 dovecot: Error: child 7559 (imap) killed with signal 6 (core dumps disabled) if ($e eq 'socket closed while reading data from server') { + warn "Can't search '$_': $e\n"; $imap->connect or die "Could not connect to IMAP server: $@\n"; } else { - die "Can't search: $e\n"; + die "Can't search '$_': $e\n"; } } @@ -112,20 +126,20 @@ } my @headers = qw(subject from to cc bcc date); -for ( sort keys %{$mids} ) { +for my $f ( sort keys %{$mids} ) { - my $m = $mids->{$_}; + my $m = $mids->{$f}; if ( @{$m} ) { - $imap->examine($_) + $imap->examine($f) or die "Can't examine: " . $imap->LastError . "\n"; - my $h = $imap->parse_headers( $mids->{$_}, @headers ) + my $h = $imap->parse_headers( $mids->{$f}, @headers ) or die "Can't get summaries: " . $imap->LastError . "\n"; for my $id ( keys %{$h} ) { - print "\n[$id]\n"; + print "\n[$f] [$id]\n"; for my $hn (@headers) { print ucfirst $hn . ": $_\n" for @{$h->{$id}->{$hn}}; }