]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiSavedSearch.pm
www: move mirror instructions to /text/
[public-inbox.git] / lib / PublicInbox / LeiSavedSearch.pm
index cfbf68c3491a9405480fa42e4f270de90e36fa92..fd51fe38681612c6f9f07a7aec888a3700e1d160 100644 (file)
@@ -115,9 +115,16 @@ sub up { # updating existing saved search via "lei up"
 sub new { # new saved search "lei q --save"
        my ($cls, $lei) = @_;
        my $self = bless { ale => $lei->ale }, $cls;
+       require File::Path;
        my $dst = $lei->{ovv}->{dst};
+
+       # canonicalize away relative paths into the config
+       if ($lei->{ovv}->{fmt} eq 'maildir' &&
+                       $dst =~ m!(?:/*|\A)\.\.(?:/*|\z)! && !-d $dst) {
+               File::Path::make_path($dst);
+               $lei->{ovv}->{dst} = $dst = $lei->abs_path($dst);
+       }
        my $dir = lss_dir_for($lei, \$dst);
-       require File::Path;
        File::Path::make_path($dir); # raises on error
        $self->{-cfg} = {};
        my $f = $self->{'-f'} = "$dir/lei.saved-search";
@@ -236,6 +243,16 @@ sub pause_dedupe {
        $oidx->commit_lazy;
 }
 
+sub reset_dedupe {
+       my ($self) = @_;
+       prepare_dedupe($self);
+       my $lk = $self->lock_for_scope_fast;
+       for my $t (qw(xref3 over id2num)) {
+               $self->{oidx}->{dbh}->do("DELETE FROM $t");
+       }
+       pause_dedupe($self);
+}
+
 sub mm { undef }
 
 sub altid_map { {} }