@@ -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 )
0 commit comments