Delete unused checkpoints (#27260)

Release Notes:

- N/A
This commit is contained in:
Antonio Scandurra 2025-03-21 17:39:01 +01:00 committed by GitHub
parent a52e2f9553
commit 0e9e2d70cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 177 additions and 67 deletions

View file

@ -549,8 +549,7 @@ impl GitStore {
}
cx.background_executor().spawn(async move {
let checkpoints: Vec<GitRepositoryCheckpoint> =
future::try_join_all(checkpoints).await?;
let checkpoints = future::try_join_all(checkpoints).await?;
Ok(GitStoreCheckpoint {
checkpoints_by_dot_git_abs_path: dot_git_abs_paths
.into_iter()
@ -617,6 +616,26 @@ impl GitStore {
})
}
pub fn delete_checkpoint(&self, checkpoint: GitStoreCheckpoint, cx: &App) -> Task<Result<()>> {
let repositories_by_dot_git_abs_path = self
.repositories
.values()
.map(|repo| (repo.read(cx).dot_git_abs_path.clone(), repo))
.collect::<HashMap<_, _>>();
let mut tasks = Vec::new();
for (dot_git_abs_path, checkpoint) in checkpoint.checkpoints_by_dot_git_abs_path {
if let Some(repository) = repositories_by_dot_git_abs_path.get(&dot_git_abs_path) {
let delete = repository.read(cx).delete_checkpoint(checkpoint);
tasks.push(async move { delete.await? });
}
}
cx.background_spawn(async move {
future::try_join_all(tasks).await?;
Ok(())
})
}
/// Blames a buffer.
pub fn blame_buffer(
&self,
@ -3319,6 +3338,20 @@ impl Repository {
}
})
}
pub fn delete_checkpoint(
&self,
checkpoint: GitRepositoryCheckpoint,
) -> oneshot::Receiver<Result<()>> {
self.send_job(move |repo, cx| async move {
match repo {
RepositoryState::Local(git_repository) => {
git_repository.delete_checkpoint(checkpoint, cx).await
}
RepositoryState::Remote { .. } => Err(anyhow!("not implemented yet")),
}
})
}
}
fn get_permalink_in_rust_registry_src(