]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: janky $PATH2CFG garbage collection
authorEric Wong <e@80x24.org>
Thu, 25 Mar 2021 04:20:18 +0000 (06:20 +0200)
committerEric Wong <e@80x24.org>
Thu, 25 Mar 2021 17:58:56 +0000 (17:58 +0000)
We need to rely on this to keep our config cache (and lei_store
pipes) under control with tests each creating a new config and
directory.

lib/PublicInbox/LEI.pm

index e521176429cb845d78eb7be7603c7380640cc417..d534f1d04e8dfce9747b73efbad230c18368c220 100644 (file)
@@ -705,6 +705,12 @@ sub _lei_cfg ($;$) {
                        File::Spec->canonpath($cfg->{'leistore.dir'})) {
                $cfg->{-lei_store} = $sto;
        }
+       if (scalar(keys %PATH2CFG) > 5) {
+               # FIXME: use inotify/EVFILT_VNODE to detect unlinked configs
+               for my $k (keys %PATH2CFG) {
+                       delete($PATH2CFG{$k}) unless -f $k
+               }
+       }
        $self->{cfg} = $PATH2CFG{$f} = $cfg;
 }