summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-05-26 23:01:18 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-05-26 23:01:18 +0200
commitefc6d9d36168a18a134a079c0321a66e2ef375ab (patch)
tree4f9fc86ccc31cfa96fd754df75d70b2ddf8afa0a
parentd9379fd4f43dc7888d5fb82630ddd9b0bfa9e892 (diff)
downloadmum-efc6d9d36168a18a134a079c0321a66e2ef375ab.tar.gz
m-pop: Fix offset bug
-rwxr-xr-xsrc/m-pop9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/m-pop b/src/m-pop
index 1a0e0ff..e7cebae 100755
--- a/src/m-pop
+++ b/src/m-pop
@@ -28,15 +28,21 @@ USAGE
open my $tty, '+<:unix', '/dev/tty' or die "Could not open /dev/tty: $!";
# Get UIDs of existing messages
-my ($mbox, $index, @existing_uids);
+my ($mbox, $index, $offset, $length, @existing_uids);
+$offset = -1;
+$length = 0;
if (-e $opt{i}) {
open $index, '<', $opt{i} or die "Could not open $opt{i}: $!";
local $/ = ''; # paragraph mode
while (<$index>) {
push @existing_uids, $1 if /^M-UID: (.*)$/m;
+ $offset = $1 if /^M-Offset: (.*)$/m;
+ $length = $1 if /^M-Length: (.*)$/m;
}
close $index;
}
+$offset += $length;
+$offset++;
# Open mbox and index files for appending
open $mbox, '>>', $opt{m} or die "Could not open $opt{m}: $!";
@@ -69,7 +75,6 @@ $SIG{INT} = sub {
# Append new messages to mbox and index files
chomp(my $date = asctime(localtime(time)));
-my $offset = 0;
my $i = 0;
for my $id (@ids) {