Add proto fields for repository entry maintenance
This commit is contained in:
parent
c6d7ed33c2
commit
2fe5bf419b
4 changed files with 40 additions and 3 deletions
|
@ -1063,6 +1063,8 @@ async fn rejoin_room(
|
||||||
removed_entries: worktree.removed_entries,
|
removed_entries: worktree.removed_entries,
|
||||||
scan_id: worktree.scan_id,
|
scan_id: worktree.scan_id,
|
||||||
is_last_update: worktree.completed_scan_id == worktree.scan_id,
|
is_last_update: worktree.completed_scan_id == worktree.scan_id,
|
||||||
|
//TODO repo
|
||||||
|
updated_repositories: vec![],
|
||||||
};
|
};
|
||||||
for update in proto::split_worktree_update(message, MAX_CHUNK_SIZE) {
|
for update in proto::split_worktree_update(message, MAX_CHUNK_SIZE) {
|
||||||
session.peer.send(session.connection_id, update.clone())?;
|
session.peer.send(session.connection_id, update.clone())?;
|
||||||
|
@ -1383,6 +1385,8 @@ async fn join_project(
|
||||||
removed_entries: Default::default(),
|
removed_entries: Default::default(),
|
||||||
scan_id: worktree.scan_id,
|
scan_id: worktree.scan_id,
|
||||||
is_last_update: worktree.scan_id == worktree.completed_scan_id,
|
is_last_update: worktree.scan_id == worktree.completed_scan_id,
|
||||||
|
// TODO repo
|
||||||
|
updated_repositories: vec![],
|
||||||
};
|
};
|
||||||
for update in proto::split_worktree_update(message, MAX_CHUNK_SIZE) {
|
for update in proto::split_worktree_update(message, MAX_CHUNK_SIZE) {
|
||||||
session.peer.send(session.connection_id, update.clone())?;
|
session.peer.send(session.connection_id, update.clone())?;
|
||||||
|
|
|
@ -43,6 +43,7 @@ use std::{
|
||||||
future::Future,
|
future::Future,
|
||||||
mem,
|
mem,
|
||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
|
os::unix::prelude::OsStrExt,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
sync::{
|
sync::{
|
||||||
|
@ -143,6 +144,18 @@ impl RepositoryEntry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<&RepositoryEntry> for proto::RepositoryEntry {
|
||||||
|
fn from(value: &RepositoryEntry) -> Self {
|
||||||
|
proto::RepositoryEntry {
|
||||||
|
git_dir_entry_id: value.git_dir_entry_id.to_proto(),
|
||||||
|
scan_id: value.scan_id as u64,
|
||||||
|
git_dir_path: value.git_dir_path.as_os_str().as_bytes().to_vec(),
|
||||||
|
work_directory: value.work_directory.0.as_os_str().as_bytes().to_vec(),
|
||||||
|
branch: value.branch.as_ref().map(|str| str.to_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// This path corresponds to the 'content path' (the folder that contains the .git)
|
/// This path corresponds to the 'content path' (the folder that contains the .git)
|
||||||
#[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq)]
|
#[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq)]
|
||||||
pub struct RepositoryWorkDirectory(Arc<Path>);
|
pub struct RepositoryWorkDirectory(Arc<Path>);
|
||||||
|
@ -1542,6 +1555,7 @@ impl LocalSnapshot {
|
||||||
removed_entries: Default::default(),
|
removed_entries: Default::default(),
|
||||||
scan_id: self.scan_id as u64,
|
scan_id: self.scan_id as u64,
|
||||||
is_last_update: true,
|
is_last_update: true,
|
||||||
|
updated_repositories: self.repository_entries.values().map(Into::into).collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1610,6 +1624,8 @@ impl LocalSnapshot {
|
||||||
removed_entries,
|
removed_entries,
|
||||||
scan_id: self.scan_id as u64,
|
scan_id: self.scan_id as u64,
|
||||||
is_last_update: self.completed_scan_id == self.scan_id,
|
is_last_update: self.completed_scan_id == self.scan_id,
|
||||||
|
// TODO repo
|
||||||
|
updated_repositories: vec![],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -329,9 +329,10 @@ message UpdateWorktree {
|
||||||
string root_name = 3;
|
string root_name = 3;
|
||||||
repeated Entry updated_entries = 4;
|
repeated Entry updated_entries = 4;
|
||||||
repeated uint64 removed_entries = 5;
|
repeated uint64 removed_entries = 5;
|
||||||
uint64 scan_id = 6;
|
repeated RepositoryEntry updated_repositories = 6;
|
||||||
bool is_last_update = 7;
|
uint64 scan_id = 7;
|
||||||
string abs_path = 8;
|
bool is_last_update = 8;
|
||||||
|
string abs_path = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
message CreateProjectEntry {
|
message CreateProjectEntry {
|
||||||
|
@ -979,6 +980,14 @@ message Entry {
|
||||||
bool is_ignored = 7;
|
bool is_ignored = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message RepositoryEntry {
|
||||||
|
uint64 git_dir_entry_id = 1;
|
||||||
|
uint64 scan_id = 2;
|
||||||
|
bytes git_dir_path = 3;
|
||||||
|
bytes work_directory = 4;
|
||||||
|
optional string branch = 5;
|
||||||
|
}
|
||||||
|
|
||||||
message BufferState {
|
message BufferState {
|
||||||
uint64 id = 1;
|
uint64 id = 1;
|
||||||
optional File file = 2;
|
optional File file = 2;
|
||||||
|
|
|
@ -502,6 +502,13 @@ pub fn split_worktree_update(
|
||||||
.drain(..removed_entries_chunk_size)
|
.drain(..removed_entries_chunk_size)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
let updated_repositories_chunk_size =
|
||||||
|
cmp::min(message.updated_repositories.len(), max_chunk_size);
|
||||||
|
let updated_repositories = message
|
||||||
|
.updated_repositories
|
||||||
|
.drain(..updated_repositories_chunk_size)
|
||||||
|
.collect();
|
||||||
|
|
||||||
done = message.updated_entries.is_empty() && message.removed_entries.is_empty();
|
done = message.updated_entries.is_empty() && message.removed_entries.is_empty();
|
||||||
Some(UpdateWorktree {
|
Some(UpdateWorktree {
|
||||||
project_id: message.project_id,
|
project_id: message.project_id,
|
||||||
|
@ -512,6 +519,7 @@ pub fn split_worktree_update(
|
||||||
removed_entries,
|
removed_entries,
|
||||||
scan_id: message.scan_id,
|
scan_id: message.scan_id,
|
||||||
is_last_update: done && message.is_last_update,
|
is_last_update: done && message.is_last_update,
|
||||||
|
updated_repositories,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue