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 C71EB20248; Wed, 17 Apr 2019 11:43:58 +0000 (UTC) Date: Wed, 17 Apr 2019 11:43:58 +0000 From: Eric Wong To: meta@public-inbox.org Subject: [RFC] inbox: add `modified' sub Message-ID: <20190417114358.ab2hsmzo7eeehghs@dcvr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline List-Id: For inboxes with SQLite enabled (all v2, and probably most v1); stat-ing the msgmap.sqlite3 file is a much faster way of telling when an inbox is modified compared to scanning git branches. --- RFC since I'm not so sure about this one. It's probably fine, but mtime may be worth considering over ctime, too... (somebody could be using atomic-rsync on the SQLite and Xapian stuff because indexing is slow) lib/PublicInbox/Inbox.pm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index cde4625..fa41ab6 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -333,4 +333,18 @@ sub recent { search($self)->{over_ro}->recent($opts, $after, $before); } +sub modified { + my ($self) = @_; + my $dir = $self->{mainrepo}; + my @st; + if ($self->{version} >= 2) { + @st = stat("$dir/msgmap.sqlite3") + } elsif (-f "$dir/public-inbox/msgmap.sqlite3") { # v1 + @st = stat(_); + } else { # v1 repos did not need sqlite3 + return git($self)->modified; + } + @st ? $st[10] : time; # 10: ctime +} + 1; -- EW