Fix logic error when streaming ignored entries
We were calling `next` twice, which led us to skip every other entry. This commit also enhances the `test_share_project` integration test to exercise this new streaming logic.
This commit is contained in:
parent
94e70bc1a6
commit
85f228dade
2 changed files with 32 additions and 14 deletions
|
@ -1696,8 +1696,13 @@ mod tests {
|
||||||
fs.insert_tree(
|
fs.insert_tree(
|
||||||
"/a",
|
"/a",
|
||||||
json!({
|
json!({
|
||||||
|
".gitignore": "ignored-dir",
|
||||||
"a.txt": "a-contents",
|
"a.txt": "a-contents",
|
||||||
"b.txt": "b-contents",
|
"b.txt": "b-contents",
|
||||||
|
"ignored-dir": {
|
||||||
|
"c.txt": "",
|
||||||
|
"d.txt": "",
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
@ -1727,7 +1732,6 @@ mod tests {
|
||||||
// Join that project as client B
|
// Join that project as client B
|
||||||
let client_b_peer_id = client_b.peer_id;
|
let client_b_peer_id = client_b.peer_id;
|
||||||
let project_b = client_b.build_remote_project(&project_a, cx_a, cx_b).await;
|
let project_b = client_b.build_remote_project(&project_a, cx_a, cx_b).await;
|
||||||
|
|
||||||
let replica_id_b = project_b.read_with(cx_b, |project, _| {
|
let replica_id_b = project_b.read_with(cx_b, |project, _| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
project
|
project
|
||||||
|
@ -1740,16 +1744,27 @@ mod tests {
|
||||||
);
|
);
|
||||||
project.replica_id()
|
project.replica_id()
|
||||||
});
|
});
|
||||||
project_a
|
|
||||||
.condition(&cx_a, |tree, _| {
|
deterministic.run_until_parked();
|
||||||
tree.collaborators()
|
project_a.read_with(cx_a, |project, _| {
|
||||||
.get(&client_b_peer_id)
|
let client_b_collaborator = project.collaborators().get(&client_b_peer_id).unwrap();
|
||||||
.map_or(false, |collaborator| {
|
assert_eq!(client_b_collaborator.replica_id, replica_id_b);
|
||||||
collaborator.replica_id == replica_id_b
|
assert_eq!(client_b_collaborator.user.github_login, "user_b");
|
||||||
&& collaborator.user.github_login == "user_b"
|
});
|
||||||
})
|
project_b.read_with(cx_b, |project, cx| {
|
||||||
})
|
let worktree = project.worktrees(cx).next().unwrap().read(cx);
|
||||||
.await;
|
assert_eq!(
|
||||||
|
worktree.paths().map(AsRef::as_ref).collect::<Vec<_>>(),
|
||||||
|
[
|
||||||
|
Path::new(".gitignore"),
|
||||||
|
Path::new("a.txt"),
|
||||||
|
Path::new("b.txt"),
|
||||||
|
Path::new("ignored-dir"),
|
||||||
|
Path::new("ignored-dir/c.txt"),
|
||||||
|
Path::new("ignored-dir/d.txt"),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
// Open the same file as client B and client A.
|
// Open the same file as client B and client A.
|
||||||
let buffer_b = project_b
|
let buffer_b = project_b
|
||||||
|
|
|
@ -963,7 +963,11 @@ impl LocalWorktree {
|
||||||
.filter(|e| e.is_ignored);
|
.filter(|e| e.is_ignored);
|
||||||
let mut ignored_entries_to_send = Vec::new();
|
let mut ignored_entries_to_send = Vec::new();
|
||||||
loop {
|
loop {
|
||||||
const CHUNK_SIZE: usize = 256;
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
|
const CHUNK_SIZE: usize = 2;
|
||||||
|
#[cfg(not(any(test, feature = "test-support")))]
|
||||||
|
const CHUNK_SIZE: usize = 128;
|
||||||
|
|
||||||
let entry = ignored_entries.next();
|
let entry = ignored_entries.next();
|
||||||
if ignored_entries_to_send.len() >= CHUNK_SIZE || entry.is_none() {
|
if ignored_entries_to_send.len() >= CHUNK_SIZE || entry.is_none() {
|
||||||
rpc.request(proto::UpdateWorktree {
|
rpc.request(proto::UpdateWorktree {
|
||||||
|
@ -977,7 +981,7 @@ impl LocalWorktree {
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(entry) = ignored_entries.next() {
|
if let Some(entry) = entry {
|
||||||
ignored_entries_to_send.push(entry.into());
|
ignored_entries_to_send.push(entry.into());
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -1179,7 +1183,6 @@ impl Snapshot {
|
||||||
|
|
||||||
for entry in update.updated_entries {
|
for entry in update.updated_entries {
|
||||||
let entry = Entry::try_from((&self.root_char_bag, entry))?;
|
let entry = Entry::try_from((&self.root_char_bag, entry))?;
|
||||||
println!("{:?} = {}", &entry.path, entry.is_ignored);
|
|
||||||
if let Some(PathEntry { path, .. }) = self.entries_by_id.get(&entry.id, &()) {
|
if let Some(PathEntry { path, .. }) = self.entries_by_id.get(&entry.id, &()) {
|
||||||
entries_by_path_edits.push(Edit::Remove(PathKey(path.clone())));
|
entries_by_path_edits.push(Edit::Remove(PathKey(path.clone())));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue