]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiXSearch.pm
lei_saved_search: expand only/include/exclude to absolute paths
[public-inbox.git] / lib / PublicInbox / LeiXSearch.pm
index 6f8770191ee6a28b36b1f7f631cbb9ebc7b26e86..730df1f772f12da20821b3546e4e459b57419689 100644 (file)
@@ -103,13 +103,6 @@ sub smsg_for {
        $smsg;
 }
 
-sub recent {
-       my ($self, $qstr, $opt) = @_;
-       $opt //= {};
-       $opt->{relevance} //= -2;
-       $self->mset($qstr //= 'z:1..', $opt);
-}
-
 sub over {}
 
 sub _check_mset_limit ($$$) {
@@ -612,34 +605,40 @@ sub add_uri {
                require IO::Uncompress::Gunzip;
                require PublicInbox::LeiCurl;
                push @{$self->{remotes}}, $uri;
+               $uri;
        } else {
                warn "curl missing, ignoring $uri\n";
+               undef;
        }
 }
 
+# returns URI or PublicInbox::Inbox-like object
 sub prepare_external {
        my ($self, $loc, $boost) = @_; # n.b. already ordered by boost
        if (ref $loc) { # already a URI, or PublicInbox::Inbox-like object
                return add_uri($self, $loc) if $loc->can('scheme');
+               # fall-through on Inbox-like objects
        } elsif ($loc =~ m!\Ahttps?://!) {
                require URI;
                return add_uri($self, URI->new($loc));
-       } elsif (-f "$loc/ei.lock") {
+       } elsif (-f "$loc/ei.lock" && -d "$loc/ALL.git/objects") {
                require PublicInbox::ExtSearch;
                die "`\\n' not allowed in `$loc'\n" if index($loc, "\n") >= 0;
                $loc = PublicInbox::ExtSearch->new($loc);
-       } elsif (-f "$loc/inbox.lock" || -d "$loc/public-inbox") {
+       } elsif ((-f "$loc/inbox.lock" && -d "$loc/all.git/objects") ||
+                       (-d "$loc/public-inbox" && -d "$loc/objects")) {
                die "`\\n' not allowed in `$loc'\n" if index($loc, "\n") >= 0;
                require PublicInbox::Inbox; # v2, v1
                $loc = bless { inboxdir => $loc }, 'PublicInbox::Inbox';
        } elsif (!-e $loc) {
                warn "W: $loc gone, perhaps run: lei forget-external $loc\n";
-               return;
+               return undef;
        } else {
                warn "W: $loc ignored, unable to determine external type\n";
-               return;
+               return undef;
        }
        push @{$self->{locals}}, $loc;
+       $loc;
 }
 
 sub _lcat_i { # LeiMailSync->each_src iterator callback