@@ -311,8 +311,13 @@ func (client *MultiRepoClient) DownloadTarget(repos []string, targetFile *metada
311
311
log := metadata .GetLogger ()
312
312
313
313
for _ , repoName := range repos {
314
+ repoClient , ok := client .TUFClients [repoName ]
315
+ if ! ok {
316
+ return "" , nil , fmt .Errorf ("no client found for repo %q" , repoName )
317
+ }
318
+
314
319
// see if the target is already present locally
315
- targetPath , targetBytes , err := client . TUFClients [ repoName ] .FindCachedTarget (targetFile , filePath )
320
+ targetPath , targetBytes , err := repoClient .FindCachedTarget (targetFile , filePath )
316
321
if err != nil {
317
322
return "" , nil , err
318
323
}
@@ -322,7 +327,7 @@ func (client *MultiRepoClient) DownloadTarget(repos []string, targetFile *metada
322
327
return targetPath , targetBytes , nil
323
328
}
324
329
// not present locally, so let's try to download it
325
- targetPath , targetBytes , err = client . TUFClients [ repoName ] .DownloadTarget (targetFile , filePath , targetBaseURL )
330
+ targetPath , targetBytes , err = repoClient .DownloadTarget (targetFile , filePath , targetBaseURL )
326
331
if err != nil {
327
332
// TODO: decide if we should error if one repository serves the expected target info, but we fail to download the actual target
328
333
// try downloading the target from the next available repository
0 commit comments