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 18EAE20248; Wed, 17 Apr 2019 19:35:07 +0000 (UTC) Date: Wed, 17 Apr 2019 19:35:06 +0000 From: Eric Wong To: meta@public-inbox.org Subject: [PATCH v2] inbox: add `modified' sub Message-ID: <20190417193506.6gradvjye5jvxeu5@dcvr> References: <20190417114358.ab2hsmzo7eeehghs@dcvr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190417114358.ab2hsmzo7eeehghs@dcvr> List-Id: > 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) -------8<---------- Subject: [PATCH] inbox: add `modified' sub 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. v2: use mtime instead of ctime for users who use generic tools to copy SQLite DBs. --- lib/PublicInbox/Inbox.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index cde4625..c004f25 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -333,4 +333,20 @@ 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; + } + # we favor 9/mtime over ctime since it should be possible to + # use generic tools such as atomic-rsync to copy SQLite DBs + @st ? $st[9] : time; +} + 1; -- EW