mirror of
https://github.com/Llewellynvdm/zoxide.git
synced 2024-11-29 07:53:55 +00:00
Canonicalize to regular paths instead of UNC paths on Windows
This commit is contained in:
parent
aab37dfab9
commit
a4b202f9da
@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
- `zoxide remove` now throws an error if there was no match in the database.
|
||||
- Interactive mode in `zoxide` no longer throws an error if `fzf` exits gracefully.
|
||||
- Canonicalize to regular paths instead of UNC paths on Windows.
|
||||
|
||||
## [0.3.1] - 2020-04-03
|
||||
|
||||
|
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -136,6 +136,11 @@ dependencies = [
|
||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dunce"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.1.14"
|
||||
@ -432,6 +437,7 @@ dependencies = [
|
||||
"bstr 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dunce 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"structopt 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -456,6 +462,7 @@ dependencies = [
|
||||
"checksum crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
|
||||
"checksum dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13aea89a5c93364a98e9b37b2fa237effbb694d5cfe01c5b70941f7eb087d5e3"
|
||||
"checksum dirs-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b"
|
||||
"checksum dunce 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0ad6bf6a88548d1126045c413548df1453d9be094a8ab9fd59bf1fdd338da4f"
|
||||
"checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
|
||||
"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
|
||||
"checksum hermit-abi 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e"
|
||||
|
@ -17,6 +17,7 @@ anyhow = "1.0.28"
|
||||
bincode = "1.2.1"
|
||||
clap = "2.33.0"
|
||||
dirs = "2.0.2"
|
||||
dunce = "1.0.0"
|
||||
serde = { version = "1.0.106", features = ["derive"] }
|
||||
structopt = "0.3.12"
|
||||
uuid = { version = "0.8.1", features = ["v4"] }
|
||||
|
@ -144,7 +144,7 @@ impl DB {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let path_abs = match Path::new(path_str).canonicalize() {
|
||||
let path_abs = match dunce::canonicalize(path_str) {
|
||||
Ok(path) => path,
|
||||
Err(e) => {
|
||||
eprintln!("invalid path '{}' at line {}: {}", path_str, line_number, e);
|
||||
@ -185,9 +185,7 @@ impl DB {
|
||||
}
|
||||
|
||||
pub fn add<P: AsRef<Path>>(&mut self, path: P, max_age: Rank, now: Epoch) -> Result<()> {
|
||||
let path_abs = path
|
||||
.as_ref()
|
||||
.canonicalize()
|
||||
let path_abs = dunce::canonicalize(&path)
|
||||
.with_context(|| anyhow!("could not access directory: {}", path.as_ref().display()))?;
|
||||
|
||||
match self.data.dirs.iter_mut().find(|dir| dir.path == path_abs) {
|
||||
@ -257,7 +255,7 @@ impl DB {
|
||||
}
|
||||
|
||||
pub fn remove<P: AsRef<Path>>(&mut self, path: P) -> Result<()> {
|
||||
if let Ok(path_abs) = path.as_ref().canonicalize() {
|
||||
if let Ok(path_abs) = dunce::canonicalize(&path) {
|
||||
self.remove_exact(path_abs)
|
||||
.or_else(|_| self.remove_exact(path))
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user