From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 373AC1FA18 for ; Tue, 12 Oct 2021 11:47:06 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 6/9] msgmap: share most of check_inodes w/ over Date: Tue, 12 Oct 2021 11:47:02 +0000 Message-Id: <20211012114705.383-7-e@80x24.org> In-Reply-To: <20211012114705.383-1-e@80x24.org> References: <20211012114705.383-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We still need to account for msgmap being open all the time and not having separate read-only vs. read-write packages. --- lib/PublicInbox/Msgmap.pm | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/lib/PublicInbox/Msgmap.pm b/lib/PublicInbox/Msgmap.pm index de9fd989..978730e2 100644 --- a/lib/PublicInbox/Msgmap.pm +++ b/lib/PublicInbox/Msgmap.pm @@ -257,21 +257,10 @@ sub skip_artnum { sub check_inodes { my ($self) = @_; - # no filename if in-:memory: - my $f = $self->{dbh}->sqlite_db_filename // return; - if (my @st = stat($f)) { # did st_dev, st_ino change? - my $st = pack('dd', $st[0], $st[1]); - if ($st ne ($self->{st} // $st)) { - my $tmp = eval { ref($self)->new_file($f) }; - if ($@) { - warn "E: DBI->connect($f): $@\n"; - } else { - %$self = %$tmp; - } - } - } else { - warn "W: stat $f: $!\n"; - } + $self->{dbh} // return; + my $rw = !$self->{dbh}->{ReadOnly}; + PublicInbox::Over::check_inodes($self); + $self->{dbh} //= PublicInbox::Over::dbh_new($self, !$rw); } 1;