aboutsummaryrefslogtreecommitdiffstats
path: root/pullimap
diff options
context:
space:
mode:
Diffstat (limited to 'pullimap')
-rwxr-xr-xpullimap10
1 files changed, 8 insertions, 2 deletions
diff --git a/pullimap b/pullimap
index d1a2f4a..e79e644 100755
--- a/pullimap
+++ b/pullimap
@@ -29,7 +29,7 @@ use Getopt::Long qw/:config posix_default no_ignore_case gnu_getopt auto_version
use List::Util 'first';
use lib 'lib';
-use Net::IMAP::InterIMAP 'read_config';
+use Net::IMAP::InterIMAP qw/read_config compact_set/;
my %CONFIG;
sub usage(;$) {
@@ -140,11 +140,16 @@ do {
writeUID(1);
}
else {
+ # put the remaining UIDs in the @ignore list: these messages
+ # have already been delivered, but the process exited before the
+ # statefile was updated
while (defined (my $uid = readUID())) {
push @ignore, $uid;
}
}
+ # use BODY.PEEK[] so if something gets wrong, unpulled messages
+ # won't be marked as \Seen in the mailbox
my $attrs = join ' ', qw/ENVELOPE INTERNALDATE BODY.PEEK[]/;
my @uid;
@@ -163,7 +168,8 @@ do {
writeUID($uid);
}, @ignore);
- # TODO mark (@ignore, @uid) as seen
+ # now that everything has been deliverd, mark @ignore and @uid as \Seen
+ $IMAP->silent_store(compact_set(@ignore, @uid), '+', '\Seen') if @ignore or @uid;
# update the statefile
sysseek($STATE, 4, SEEK_SET) // die "Can't seek: $!";