aboutsummaryrefslogtreecommitdiffstats
path: root/pullimap
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2016-03-05 15:52:27 +0100
committerGuilhem Moulin <guilhem@fripost.org>2016-03-05 15:52:27 +0100
commit56e27b9e4c27fe037695515c8afa84fd8a31cf6d (patch)
treeab018b39dca0db776c1513ba735d9eb0f6db2411 /pullimap
parente9e360cbe894b5674a3ffe433e5d727cf8368715 (diff)
pullimap: mark downloaded messages as \Seen
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: $!";