Handle repos with unknown PDS
This commit is contained in:
parent
fa8b67bcc9
commit
b2003530ba
4 changed files with 29 additions and 2 deletions
|
@ -106,6 +106,9 @@ func (s *Scheduler) fillQueue(ctx context.Context) error {
|
|||
perPDSLimit = maxQueueLen * 2 / len(remotes)
|
||||
}
|
||||
|
||||
// Fake remote to account for repos we didn't have a PDS for yet.
|
||||
remotes = append(remotes, pds.PDS{ID: pds.Unknown})
|
||||
|
||||
for _, remote := range remotes {
|
||||
repos := []repo.Repo{}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
|
||||
"github.com/uabluerail/bsky-tools/xrpcauth"
|
||||
"github.com/uabluerail/indexer/models"
|
||||
"github.com/uabluerail/indexer/pds"
|
||||
"github.com/uabluerail/indexer/repo"
|
||||
"github.com/uabluerail/indexer/util/resolver"
|
||||
)
|
||||
|
@ -192,6 +193,17 @@ retry:
|
|||
}
|
||||
reposFetched.WithLabelValues(u.String(), "true").Inc()
|
||||
|
||||
if work.Repo.PDS == pds.Unknown {
|
||||
remote, err := pds.EnsureExists(ctx, p.db, u.String())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
work.Repo.PDS = remote.ID
|
||||
if err := p.db.Model(&work.Repo).Where(&repo.Repo{ID: work.Repo.ID}).Updates(&repo.Repo{PDS: work.Repo.PDS}).Error; err != nil {
|
||||
return fmt.Errorf("failed to set repo's PDS: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
newRev, err := repo.GetRev(ctx, bytes.NewReader(b))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read 'rev' from the fetched repo: %w", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue