@@ -17,7 +17,6 @@ package resources
17
17
18
18
import (
19
19
"context"
20
- "errors"
21
20
"net/url"
22
21
"path"
23
22
"strings"
@@ -28,6 +27,7 @@ import (
28
27
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
29
28
"github.com/arduino/go-paths-helper"
30
29
"github.com/codeclysm/extract/v3"
30
+ "github.com/sirupsen/logrus"
31
31
"go.bug.st/downloader/v2"
32
32
)
33
33
@@ -68,12 +68,12 @@ func (res *IndexResource) Download(destDir *paths.Path, downloadCB rpc.DownloadP
68
68
signatureFileName := indexFileName + ".sig"
69
69
signaturePath = destDir .Join (signatureFileName )
70
70
71
- // .tar archive may contain both index and signature
71
+ // .tar.bz2 archive may contain both index and signature
72
72
73
73
// Extract archive in a tmp/archive subdirectory
74
74
f , err := tmpIndexPath .Open ()
75
75
if err != nil {
76
- return & arduino.PermissionDeniedError {Message : tr ("Error extracting %s" , tmpIndexPath ), Cause : err }
76
+ return & arduino.PermissionDeniedError {Message : tr ("Error opening %s" , tmpIndexPath ), Cause : err }
77
77
}
78
78
defer f .Close ()
79
79
tmpArchivePath := tmp .Join ("archive" )
@@ -85,14 +85,15 @@ func (res *IndexResource) Download(destDir *paths.Path, downloadCB rpc.DownloadP
85
85
// Look for index.json
86
86
tmpIndexPath = tmpArchivePath .Join (indexFileName )
87
87
if ! tmpIndexPath .Exist () {
88
- err := errors .New (tr ("%s not found" , indexFileName ))
89
- return & arduino.FailedDownloadError {Message : tr ("Invalid index archive" ), Cause : err }
88
+ return & arduino.NotFoundError {Message : tr ("Invalid archive: file %{1}s not found in archive %{2}s" , indexFileName , tmpArchivePath .Base ())}
90
89
}
91
90
92
91
// Look for signature
93
92
if t := tmpArchivePath .Join (signatureFileName ); t .Exist () {
94
93
tmpSignaturePath = t
95
94
hasSignature = true
95
+ } else {
96
+ logrus .Infof ("No signature %s found in package index archive %s" , signatureFileName , tmpArchivePath .Base ())
96
97
}
97
98
} else if strings .HasSuffix (indexFileName , ".gz" ) {
98
99
indexFileName = strings .TrimSuffix (indexFileName , ".gz" ) // == package_index.json
0 commit comments