Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LSP removing static downloads and git refs from lockfile on save #130

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions crates/brioche-core/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,32 @@ async fn load_project_inner(
.write()
.map_err(|_| anyhow::anyhow!("failed to acquire 'projects' lock"))?;

// If the lockfile doesn't need to be fully valid, ensure that
// the new lockfile includes old statics that weren't updated. This
// can mean that e.g. unnecessary downloads are kept, but this is
// appropriate for situations like the LSP
if !fully_valid {
let Lockfile {
dependencies: _,
downloads: new_downloads,
git_refs: new_git_refs,
} = &mut new_lockfile;

if let Some(lockfile) = &lockfile {
for (url, hash) in &lockfile.downloads {
new_downloads
.entry(url.clone())
.or_insert_with(|| hash.clone());
}

for (url, options) in &lockfile.git_refs {
new_git_refs
.entry(url.clone())
.or_insert_with(|| options.clone());
}
}
}

if lockfile.as_ref() != Some(&new_lockfile) {
if lockfile_required {
anyhow::bail!("lockfile at {} is out of date", lockfile_path.display());
Expand Down