mason/.perl-lib/TrivGal.pm (listdir): Set item before setting index.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 11 Jun 2023 16:45:31 +0000 (17:45 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 12 Jun 2023 10:48:39 +0000 (11:48 +0100)
Otherwise we set the index to the /previous/ item, which doesn't go so
well.  I don't know why I never noticed this before.

mason/.perl-lib/TrivGal.pm

index 193f122..eb82db2 100644 (file)
@@ -305,6 +305,7 @@ sub listdir ($) {
             $/x;
        $name = urldecode $name;
        my $list;
+       $item = TrivGal::Item->new($name);
        if ($name =~ m#/$#) {
          $list = \@d;
          die "can't index a folder" if $indexp;
@@ -317,7 +318,6 @@ sub listdir ($) {
            $ix = $item;
          }
        }
-       $item = TrivGal::Item->new($name);
        $comment = $c;
        push @$list, $item;
       }