Skip to content

Commit 56dda5c

Browse files
committed
Add an option to disable the existence check
1 parent 2299f28 commit 56dda5c

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,10 @@ Environment variables[^2] can be used for configuration. They must be set before
460460
- `_ZO_RESOLVE_SYMLINKS`
461461
- When set to 1, `z` will resolve symlinks before adding directories to the
462462
database.
463+
- `_ZO_DISABLE_EXISTENCE_CHECK`
464+
- When set to 1, `z` will not filter the list for the existing files.
465+
This improves the performance when the files on the list are on
466+
a slow drive, such as a network drive.
463467
464468
## Third-party integrations
465469

man/man1/zoxide.1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ the database. By default, this is set to 10000.
9999
.B _ZO_RESOLVE_SYMLINKS
100100
When set to 1, \fBz\fR will resolve symlinks before adding directories to
101101
the database.
102+
.TP
103+
.B _ZO_DISABLE_EXISTENCE_CHECK
104+
When set to 1, \fBz\fR will not filter the list for the existing files.
105+
This improves the performance when the files on the list are on a slow drive,
106+
such as a network drive.
102107
.SH ALGORITHM
103108
.TP
104109
.B AGING

src/cmd/cmd.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ https://github.com/ajeetdsouza/zoxide
2727
{tab}<bold>_ZO_EXCLUDE_DIRS</bold> {tab}List of directory globs to be excluded
2828
{tab}<bold>_ZO_FZF_OPTS</bold> {tab}Custom flags to pass to fzf
2929
{tab}<bold>_ZO_MAXAGE</bold> {tab}Maximum total age after which entries start getting deleted
30-
{tab}<bold>_ZO_RESOLVE_SYMLINKS</bold>{tab}Resolve symlinks when storing paths").into_resettable()
30+
{tab}<bold>_ZO_RESOLVE_SYMLINKS</bold>{tab}Resolve symlinks when storing paths
31+
{tab}<bold>_ZO_DISABLE_EXISTENCE_CHECK</bold>{tab}Do not filter the list by existing files").into_resettable()
3132
}
3233
}
3334

src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,7 @@ pub fn maxage() -> Result<Rank> {
6060
pub fn resolve_symlinks() -> bool {
6161
env::var_os("_ZO_RESOLVE_SYMLINKS").is_some_and(|var| var == "1")
6262
}
63+
64+
pub fn disable_existence_filter() -> bool {
65+
env::var_os("_ZO_DISABLE_EXISTENCE_CHECK").is_some_and(|var| var == "1")
66+
}

src/db/stream.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::{fs, path};
55

66
use glob::Pattern;
77

8+
use crate::config;
89
use crate::db::{Database, Dir, Epoch};
910
use crate::util::{self, MONTH};
1011

@@ -65,7 +66,7 @@ impl<'a> Stream<'a> {
6566
}
6667

6768
fn filter_by_exists(&self, path: &str) -> bool {
68-
if !self.options.exists {
69+
if !self.options.exists || config::disable_existence_filter() {
6970
return true;
7071
}
7172

0 commit comments

Comments
 (0)