]> Sergey Matveev's repositories - public-inbox.git/commitdiff
nntp: fix STAT command
authorEric Wong <e@yhbt.net>
Sat, 1 Aug 2020 20:16:58 +0000 (20:16 +0000)
committerEric Wong <e@yhbt.net>
Sun, 2 Aug 2020 08:25:16 +0000 (08:25 +0000)
The return value of art_lookup changed but this command wasn't
updated since it wasn't tested.

Fixes: 0e6ceff37fc38f28 ("nntp: support slow blob retrievals")
lib/PublicInbox/NNTP.pm
t/nntpd.t

index 87ddf7a4af83312e41edc775e0794066d73e6ce3..595a4046d4fccff1249784aca9d022c656cb9e08 100644 (file)
@@ -581,11 +581,11 @@ sub cmd_body ($;$) {
 
 sub cmd_stat ($;$) {
        my ($self, $art) = @_;
-       my $r = art_lookup($self, $art);
-       return $r unless ref $r;
-       my ($n, $mid) = @$r;
+       my $smsg = art_lookup($self, $art); # art may be msgid
+       return $smsg unless ref $smsg;
+       $art = $smsg->{num};
        set_art($self, $art);
-       "223 $n <$mid> article retrieved - request text separately";
+       "223 $art <$smsg->{mid}> article retrieved - request text separately";
 }
 
 sub cmd_ihave ($) { '435 article not wanted - do not send it' }
index aaf6661deaab8cbd88af8fe454adf4abc690bfa0..0b4a2636ac9d28ca925c00ab9b018f9f12eca687 100644 (file)
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -206,6 +206,7 @@ EOF
 
        is_deeply($n->head(1), $n->head('<nntp@example.com>'), 'HEAD OK');
        is_deeply($n->body(1), $n->body('<nntp@example.com>'), 'BODY OK');
+       is_deeply($n->nntpstat(1), '<nntp@example.com>', 'STAT');
        is($n->body(1)->[0], "This is a test message for El\xc3\xa9anor\n",
                'body really matches');
        my $art = $n->article(1);