mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 18:46:49 +00:00
Fix error in joining empty paths
This commit is contained in:
parent
5da2b123b5
commit
f7b2713b77
1 changed files with 35 additions and 26 deletions
|
@ -809,16 +809,16 @@ impl LocalWorktree {
|
|||
cx: &mut ModelContext<Worktree>,
|
||||
) -> Option<Task<Result<()>>> {
|
||||
let entry = self.entry_for_id(entry_id)?.clone();
|
||||
let path = entry.path.clone();
|
||||
let abs_path = self.absolutize(&path);
|
||||
let (tx, mut rx) = barrier::channel();
|
||||
|
||||
let delete = cx.background().spawn({
|
||||
let abs_path = abs_path.clone();
|
||||
let abs_path = self.abs_path.clone();
|
||||
let fs = self.fs.clone();
|
||||
async move {
|
||||
|
||||
let delete = cx.background().spawn(async move {
|
||||
let mut abs_path = fs.canonicalize(&abs_path).await?;
|
||||
if entry.path.file_name().is_some() {
|
||||
abs_path = abs_path.join(&entry.path);
|
||||
}
|
||||
if entry.is_file() {
|
||||
fs.remove_file(&abs_path, Default::default()).await
|
||||
fs.remove_file(&abs_path, Default::default()).await?;
|
||||
} else {
|
||||
fs.remove_dir(
|
||||
&abs_path,
|
||||
|
@ -827,13 +827,14 @@ impl LocalWorktree {
|
|||
ignore_if_not_exists: false,
|
||||
},
|
||||
)
|
||||
.await
|
||||
}
|
||||
.await?;
|
||||
}
|
||||
anyhow::Ok(abs_path)
|
||||
});
|
||||
|
||||
Some(cx.spawn(|this, mut cx| async move {
|
||||
delete.await?;
|
||||
let abs_path = delete.await?;
|
||||
let (tx, mut rx) = barrier::channel();
|
||||
this.update(&mut cx, |this, _| {
|
||||
this.as_local_mut()
|
||||
.unwrap()
|
||||
|
@ -912,15 +913,23 @@ impl LocalWorktree {
|
|||
cx: &mut ModelContext<Worktree>,
|
||||
) -> Task<Result<Entry>> {
|
||||
let fs = self.fs.clone();
|
||||
let abs_path = self.abs_path.clone();
|
||||
let abs_root_path = self.abs_path.clone();
|
||||
let path_changes_tx = self.path_changes_tx.clone();
|
||||
cx.spawn_weak(move |this, mut cx| async move {
|
||||
let abs_path = fs.canonicalize(&abs_path).await?;
|
||||
let paths = if let Some(old_path) = old_path {
|
||||
vec![abs_path.join(&path), abs_path.join(&old_path)]
|
||||
let abs_path = fs.canonicalize(&abs_root_path).await?;
|
||||
let mut paths = Vec::with_capacity(2);
|
||||
paths.push(if path.file_name().is_some() {
|
||||
abs_path.join(&path)
|
||||
} else {
|
||||
vec![abs_path.join(&path)]
|
||||
};
|
||||
abs_path.clone()
|
||||
});
|
||||
if let Some(old_path) = old_path {
|
||||
paths.push(if old_path.file_name().is_some() {
|
||||
abs_path.join(&old_path)
|
||||
} else {
|
||||
abs_path.clone()
|
||||
});
|
||||
}
|
||||
|
||||
let (tx, mut rx) = barrier::channel();
|
||||
path_changes_tx.unbounded_send((paths, tx)).unwrap();
|
||||
|
|
Loading…
Reference in a new issue