ImportProgress returns progress of the import job.
(ctx context.Context, session *auth.Session, repoRef string, )
| 29 | |
| 30 | // ImportProgress returns progress of the import job. |
| 31 | func (c *Controller) ImportProgress(ctx context.Context, |
| 32 | session *auth.Session, |
| 33 | repoRef string, |
| 34 | ) (job.Progress, error) { |
| 35 | // note: can't use c.getRepoCheckAccess because this needs to fetch a repo being imported. |
| 36 | repo, err := c.repoFinder.FindByRef(ctx, repoRef) |
| 37 | if err != nil { |
| 38 | return job.Progress{}, err |
| 39 | } |
| 40 | |
| 41 | if err = apiauth.CheckRepo(ctx, c.authorizer, session, repo, enum.PermissionRepoView); err != nil { |
| 42 | return job.Progress{}, err |
| 43 | } |
| 44 | |
| 45 | progress, err := c.importer.GetProgress(ctx, repo) |
| 46 | if errors.Is(err, importer.ErrNotFound) { |
| 47 | return job.Progress{}, usererror.NotFound("No recent or ongoing import found for repository.") |
| 48 | } |
| 49 | if err != nil { |
| 50 | return job.Progress{}, fmt.Errorf("failed to retrieve import progress: %w", err) |
| 51 | } |
| 52 | |
| 53 | return progress, err |
| 54 | } |
no test coverage detected