protocol: SignedRefs upgrades provide `SyncedAt`

When upgrading Signed References via `fn upgrad_sigrefs`, the value of
`RepositoryInfo::synced_at` was not updated. Thus, the caller could not
continue with migrated repositories as usual.

Now that enough information about Signed References is propagated, such
as the head of Signed References after upgrade, is available, it is
possible to construct `SyncedAt`.
This commit is contained in:
Lorenz Leutgeb 2026-03-24 22:32:49 +01:00 committed by Fintan Halpenny
parent 6d771abfcc
commit e7467fb15f
1 changed files with 12 additions and 6 deletions

View File

@ -447,10 +447,9 @@ where
let mut private = BTreeSet::new();
for repo in self.storage.repositories()? {
let repo = self.upgrade_sigrefs(repo)?;
let rid = repo.rid;
self.upgrade_sigrefs(&repo)?;
// If we're not seeding this repo, just skip it.
if !self.policies.is_seeding(&rid)? {
debug!(target: "service", "Local repository {rid} is not seeded");
@ -522,9 +521,9 @@ where
Ok(())
}
fn upgrade_sigrefs(&mut self, info: &RepositoryInfo) -> Result<(), Error> {
fn upgrade_sigrefs(&mut self, mut info: RepositoryInfo) -> Result<RepositoryInfo, Error> {
if !matches!(info.refs, SignedRefsInfo::NeedsMigration) {
return Ok(());
return Ok(info);
}
let rid = info.rid;
@ -536,8 +535,15 @@ where
let repo = self.storage.repository_mut(rid)?;
// NOTE: We assume to reach `FeatureLevel::LATEST` by signing refs.
repo.force_sign_refs(&self.signer)?;
Ok(())
let refs = repo.force_sign_refs(&self.signer)?;
let repo = self.storage.repository(rid)?;
let synced_at = SyncedAt::new(refs.at, &repo)?;
info.synced_at = Some(synced_at);
info.refs = SignedRefsInfo::Some(refs);
Ok(info)
}
}