+25
-9
lines changedFilter options
+25
-9
lines changed Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@ import (
31
31
32
32
"github.com/arduino/arduino-cli/internal/i18n"
33
33
paths "github.com/arduino/go-paths-helper"
34
+
"github.com/sirupsen/logrus"
34
35
)
35
36
36
37
// TestLocalArchiveChecksum test if the checksum of the local archive match the checksum of the DownloadResource
@@ -82,20 +83,21 @@ func (r *DownloadResource) TestLocalArchiveChecksum(downloadDir *paths.Path) (bo
82
83
}
83
84
84
85
// TestLocalArchiveSize test if the local archive size match the DownloadResource size
85
-
func (r *DownloadResource) TestLocalArchiveSize(downloadDir *paths.Path) (bool, error) {
86
+
func (r *DownloadResource) TestLocalArchiveSize(downloadDir *paths.Path) error {
86
87
filePath, err := r.ArchivePath(downloadDir)
87
88
if err != nil {
88
-
return false, errors.New(i18n.Tr("getting archive path: %s", err))
89
+
return errors.New(i18n.Tr("getting archive path: %s", err))
89
90
}
90
91
info, err := filePath.Stat()
91
92
if err != nil {
92
-
return false, errors.New(i18n.Tr("getting archive info: %s", err))
93
+
return errors.New(i18n.Tr("getting archive info: %s", err))
93
94
}
95
+
// If the size do not match, just report a warning and continue
96
+
// (the checksum is sufficient to ensure the integrity of the archive)
94
97
if info.Size() != r.Size {
95
-
return false, fmt.Errorf("%s: %d != %d", i18n.Tr("fetched archive size differs from size specified in index"), info.Size(), r.Size)
98
+
logrus.Warningf("%s: %d != %d", i18n.Tr("fetched archive size differs from size specified in index"), info.Size(), r.Size)
96
99
}
97
-
98
-
return true, nil
100
+
return nil
99
101
}
100
102
101
103
// TestLocalArchiveIntegrity checks for integrity of the local archive.
@@ -106,10 +108,8 @@ func (r *DownloadResource) TestLocalArchiveIntegrity(downloadDir *paths.Path) (b
106
108
return false, nil
107
109
}
108
110
109
-
if ok, err := r.TestLocalArchiveSize(downloadDir); err != nil {
111
+
if err := r.TestLocalArchiveSize(downloadDir); err != nil {
110
112
return false, errors.New(i18n.Tr("testing archive size: %s", err))
111
-
} else if !ok {
112
-
return false, nil
113
113
}
114
114
115
115
ok, err := r.TestLocalArchiveChecksum(downloadDir)
Original file line number Diff line number Diff line change
@@ -82,6 +82,10 @@ func TestDownloadAndChecksums(t *testing.T) {
82
82
require.NoError(t, err)
83
83
downloadAndTestChecksum()
84
84
85
+
require.NoError(t, r.TestLocalArchiveSize(tmp))
86
+
r.Size = 500
87
+
require.NoError(t, r.TestLocalArchiveSize(tmp))
88
+
85
89
r.Checksum = ""
86
90
_, err = r.TestLocalArchiveChecksum(tmp)
87
91
require.Error(t, err)
Original file line number Diff line number Diff line change
@@ -1354,3 +1354,15 @@ func TestReferencedCoreBuildAndRuntimeProperties(t *testing.T) {
1354
1354
out.ArrayMustContain(jsonEncode("runtime.platform.path=" + corePlatformPath))
1355
1355
}
1356
1356
}
1357
+
1358
+
func TestCoreInstallWithWrongArchiveSize(t *testing.T) {
1359
+
// See: https://github.com/arduino/arduino-cli/issues/2332
1360
+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
1361
+
defer env.CleanUp()
1362
+
1363
+
_, _, err := cli.Run("--additional-urls", "https://raw.githubusercontent.com/geolink/opentracker-arduino-board/bf6158ebab0402db217bfb02ea61461ddc6f2940/package_opentracker_index.json", "core", "update-index")
1364
+
require.NoError(t, err)
1365
+
1366
+
_, _, err = cli.Run("--additional-urls", "https://raw.githubusercontent.com/geolink/opentracker-arduino-board/bf6158ebab0402db217bfb02ea61461ddc6f2940/package_opentracker_index.json", "core", "install", "opentracker:sam@1.0.5")
1367
+
require.NoError(t, err)
1368
+
}
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4