diff options
author | John Ankarström <john@ankarstrom.se> | 2021-05-26 23:01:18 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-05-26 23:01:18 +0200 |
commit | efc6d9d36168a18a134a079c0321a66e2ef375ab (patch) | |
tree | 4f9fc86ccc31cfa96fd754df75d70b2ddf8afa0a | |
parent | d9379fd4f43dc7888d5fb82630ddd9b0bfa9e892 (diff) | |
download | mum-efc6d9d36168a18a134a079c0321a66e2ef375ab.tar.gz |
m-pop: Fix offset bug
-rwxr-xr-x | src/m-pop | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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) { |