Don't eagerly populate copied subdirectory
This can race anyway with snapshot updates, so we just eagerly refresh the root entry and wait for updates to come in to populate it.
This commit is contained in:
parent
604b737d7c
commit
354488ebdf
5 changed files with 43 additions and 126 deletions
|
@ -785,7 +785,7 @@ impl Project {
|
|||
entry_id: ProjectEntryId,
|
||||
new_path: impl Into<Arc<Path>>,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> Option<Task<Result<(Entry, Vec<Entry>)>>> {
|
||||
) -> Option<Task<Result<Entry>>> {
|
||||
let worktree = self.worktree_for_entry(entry_id, cx)?;
|
||||
let new_path = new_path.into();
|
||||
if self.is_local() {
|
||||
|
@ -810,24 +810,15 @@ impl Project {
|
|||
let entry = response
|
||||
.entry
|
||||
.ok_or_else(|| anyhow!("missing entry in response"))?;
|
||||
let (entry, child_entries) = worktree.update(&mut cx, |worktree, cx| {
|
||||
let worktree = worktree.as_remote().unwrap();
|
||||
let root_entry =
|
||||
worktree.insert_entry(entry, response.worktree_scan_id as usize, cx);
|
||||
let mut child_entries = Vec::new();
|
||||
for entry in response.child_entries {
|
||||
child_entries.push(worktree.insert_entry(
|
||||
worktree
|
||||
.update(&mut cx, |worktree, cx| {
|
||||
worktree.as_remote().unwrap().insert_entry(
|
||||
entry,
|
||||
response.worktree_scan_id as usize,
|
||||
cx,
|
||||
));
|
||||
}
|
||||
(root_entry, child_entries)
|
||||
});
|
||||
Ok((
|
||||
entry.await?,
|
||||
futures::future::try_join_all(child_entries).await?,
|
||||
))
|
||||
)
|
||||
})
|
||||
.await
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
@ -4058,7 +4049,6 @@ impl Project {
|
|||
.await?;
|
||||
Ok(proto::ProjectEntryResponse {
|
||||
entry: Some((&entry).into()),
|
||||
child_entries: Default::default(),
|
||||
worktree_scan_id: worktree_scan_id as u64,
|
||||
})
|
||||
}
|
||||
|
@ -4087,7 +4077,6 @@ impl Project {
|
|||
.await?;
|
||||
Ok(proto::ProjectEntryResponse {
|
||||
entry: Some((&entry).into()),
|
||||
child_entries: Default::default(),
|
||||
worktree_scan_id: worktree_scan_id as u64,
|
||||
})
|
||||
}
|
||||
|
@ -4104,7 +4093,7 @@ impl Project {
|
|||
.ok_or_else(|| anyhow!("worktree not found"))
|
||||
})?;
|
||||
let worktree_scan_id = worktree.read_with(&cx, |worktree, _| worktree.scan_id());
|
||||
let (entry, child_entries) = worktree
|
||||
let entry = worktree
|
||||
.update(&mut cx, |worktree, cx| {
|
||||
let new_path = PathBuf::from(OsString::from_vec(envelope.payload.new_path));
|
||||
worktree
|
||||
|
@ -4116,7 +4105,6 @@ impl Project {
|
|||
.await?;
|
||||
Ok(proto::ProjectEntryResponse {
|
||||
entry: Some((&entry).into()),
|
||||
child_entries: child_entries.iter().map(Into::into).collect(),
|
||||
worktree_scan_id: worktree_scan_id as u64,
|
||||
})
|
||||
}
|
||||
|
@ -4144,7 +4132,6 @@ impl Project {
|
|||
.await?;
|
||||
Ok(proto::ProjectEntryResponse {
|
||||
entry: None,
|
||||
child_entries: Default::default(),
|
||||
worktree_scan_id: worktree_scan_id as u64,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue