diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2016-03-05 15:52:27 +0100 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2016-03-05 15:52:27 +0100 |
commit | 56e27b9e4c27fe037695515c8afa84fd8a31cf6d (patch) | |
tree | ab018b39dca0db776c1513ba735d9eb0f6db2411 /pullimap | |
parent | e9e360cbe894b5674a3ffe433e5d727cf8368715 (diff) |
pullimap: mark downloaded messages as \Seen
Diffstat (limited to 'pullimap')
-rwxr-xr-x | pullimap | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -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: $!"; |