$ENV{"MHCONTEXT"} = $mh . '/.minc.context';
-# TODO: Support dot-locking too. This works on FreeBSD and Linux.
-my $locking = `mhparam datalocking`;
-$? < 0 && die;
-$? == 0 || die('mhparam datalocking: ' . exit_msg($?));
-chomp($locking);
-if ($locking ne 'fcntl') {
- die("mh locking $locking not supported; only fcntl");
-}
+my $SEQ_FILE;
+my $UNSEEN;
\f
###############################################################################
}
sub mark {
+ $SEQ_FILE or return;
my $folder = shift;
my $msgnum = shift;
my $seq = shift;
- my $fn = "$mh/$folder/.mh_sequences";
+ my $fn = "$mh/$folder/$SEQ_FILE";
my ($fh, $e) = lkopen_fcntl($fn, O_RDWR | O_CREAT, 0600);
my @sequences = <$fh>;
# fails. While it is slow, it is not safe to store multiple
# messages and then have a failure before marking some (or
# all).
- if ($mhfolder ne 'SPAM') {
- mark($mhfolder, $dst_msgnum, 'unseen');
+ if ($UNSEEN and $mhfolder ne 'SPAM') {
+ mark($mhfolder, $dst_msgnum, $UNSEEN);
}
}
}
require "$HOME/.minc";
}
+ my $locking = '';
+ open(my $fh, '-|', 'mhparam',
+ 'datalocking', 'mh-sequences', 'unseen-sequence') or die("open(mhparam|): $!");
+ while (<$fh>) {
+ chomp;
+ if (s/^fcntl:\s*//) {
+ $locking = $_;
+ } elsif (s/^mh-sequences:\s*//) {
+ $SEQ_FILE = $_;
+ } elsif (s/unseen-sequence:\s*//) {
+ $UNSEEN = $_;
+ }
+ }
+ if (!close($fh)) {
+ $! == 0 or die("open(mhparam|): $!");
+ die('mhparam '. exit_msg($?));
+ }
+
+ # TODO: Support dot-locking too. This works on FreeBSD and Linux.
+ if ($locking ne 'fcntl') {
+ die("mh locking '$locking' not supported; only fcntl");
+ }
+
my $inbox;
if ($MAILDIR) {
$inbox = $MAILDIR;