about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiSavedSearch.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-08-11 11:26:17 +0000
committerEric Wong <e@80x24.org>2021-08-11 21:50:08 +0000
commitd15e80db44399867d8ca53528e38f70f54562b88 (patch)
tree40e1f4d12f3ca6a88b9e149ad4f85c6e9884ee8a /lib/PublicInbox/LeiSavedSearch.pm
parent4c6f9a39621fdae852e0655b7db3d61f03c716c5 (diff)
downloadpublic-inbox-d15e80db44399867d8ca53528e38f70f54562b88.tar.gz
Storing relative paths with '..' in them can be expensive to
resolve when running 'lei up', so prefer storing canonicalized
absolute paths.  We only do this for paths with '..' in them,
though, since this can lose symlink info.
Diffstat (limited to 'lib/PublicInbox/LeiSavedSearch.pm')
-rw-r--r--lib/PublicInbox/LeiSavedSearch.pm9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/PublicInbox/LeiSavedSearch.pm b/lib/PublicInbox/LeiSavedSearch.pm
index cfbf68c3..2a0e9321 100644
--- a/lib/PublicInbox/LeiSavedSearch.pm
+++ b/lib/PublicInbox/LeiSavedSearch.pm
@@ -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";