From 56e27b9e4c27fe037695515c8afa84fd8a31cf6d Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sat, 5 Mar 2016 15:52:27 +0100 Subject: pullimap: mark downloaded messages as \Seen --- pullimap | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'pullimap') 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: $!"; -- cgit v1.2.3