Skip to content

Commit

Permalink
potential nil pointer dereference
Browse files Browse the repository at this point in the history
Signed-off-by: mrdan4es <mrdan4es@gmail.com>
  • Loading branch information
MrDan4es committed Nov 20, 2024
1 parent 40cd269 commit 59b3c0d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions metadata/multirepo/multirepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,14 @@ func (client *MultiRepoClient) DownloadTarget(repos []string, targetFile *metada
log := metadata.GetLogger()

for _, repoName := range repos {
repoClient, ok := client.TUFClients[repoName]
if !ok {
log.Error(fmt.Errorf("client not found"), "No client found for this repo", "repo", repoName)
continue
}

// see if the target is already present locally
targetPath, targetBytes, err := client.TUFClients[repoName].FindCachedTarget(targetFile, filePath)
targetPath, targetBytes, err := repoClient.FindCachedTarget(targetFile, filePath)
if err != nil {
return "", nil, err
}
Expand All @@ -322,7 +328,7 @@ func (client *MultiRepoClient) DownloadTarget(repos []string, targetFile *metada
return targetPath, targetBytes, nil
}
// not present locally, so let's try to download it
targetPath, targetBytes, err = client.TUFClients[repoName].DownloadTarget(targetFile, filePath, targetBaseURL)
targetPath, targetBytes, err = repoClient.DownloadTarget(targetFile, filePath, targetBaseURL)
if err != nil {
// TODO: decide if we should error if one repository serves the expected target info, but we fail to download the actual target
// try downloading the target from the next available repository
Expand Down

0 comments on commit 59b3c0d

Please sign in to comment.