Skip to content

Commit 18815e5

Browse files
committed
refactoring
1 parent f6e7feb commit 18815e5

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

cmd/arduino_lib.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,10 @@ func executeInstallCommand(cmd *cobra.Command, args []string) error {
220220
}
221221
}
222222

223-
libs, failed := purgeInvalidItems(releases.ParseArgs(args), status)
223+
parsedArgs := releases.ParseArgs(args)
224+
libs, failOutputs := purgeInvalidItems(parsedArgs, status)
224225
outputResults := output.LibProcessResults{
225-
Libraries: failed,
226+
Libraries: failOutputs,
226227
}
227228
releases.ParallelDownloads(libs, false, "Installed", GlobalFlags.Verbose, &outputResults.Libraries)
228229

common/releases/helpers.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,16 @@ func ParallelDownloads(items []DownloadItem, forced bool, OkStatus string, verbo
135135
progressBars := make([]*pb.ProgressBar, 0, itemC)
136136
textMode := formatter.IsCurrentFormat("text")
137137
for _, item := range items {
138-
if forced || item.Release != nil && (!IsCached(item.Release) || item.Release.CheckLocalArchive() != nil) {
138+
cached := IsCached(item.Release)
139+
releaseNotNil := item.Release != nil
140+
if forced || releaseNotNil && (!cached || item.Release.CheckLocalArchive() != nil) {
139141
var pBar *pb.ProgressBar
140142
if textMode {
141143
pBar = pb.StartNew(int(item.Release.ArchiveSize())).SetUnits(pb.U_BYTES).Prefix(fmt.Sprintf("%-20s", item.Name))
142144
progressBars = append(progressBars, pBar)
143145
}
144146
tasks[item.Name] = downloadAndCache(item, pBar)
145-
} else if !forced && item.Release != nil && IsCached(item.Release) {
147+
} else if !forced && releaseNotNil && cached {
146148
//Consider OK
147149
*refResults = append(*refResults, output.ProcessResult{
148150
ItemName: item.Name,

cores/download.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ import (
3434
)
3535

3636
const (
37-
//PackageIndexURL contains the index URL for core packages.
38-
PackageIndexURL = "http://downloads.arduino.cc/packages/package_index.json"
37+
//packageIndexURL contains the index URL for core packages.
38+
packageIndexURL = "http://downloads.arduino.cc/packages/package_index.json"
3939
)
4040

4141
// getDownloadCacheFolder gets the folder where temp installs are stored until installation complete (libraries).
@@ -45,7 +45,7 @@ func getDownloadCacheFolder() (string, error) {
4545

4646
// DownloadPackagesFile downloads the core packages index file from arduino repository.
4747
func DownloadPackagesFile() error {
48-
return common.DownloadPackageIndex(IndexPath, PackageIndexURL)
48+
return common.DownloadPackageIndex(IndexPath, packageIndexURL)
4949
}
5050

5151
// download core

libraries/download.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ import (
3434
)
3535

3636
const (
37-
// LibraryIndexURL is the URL where to get library index.
38-
LibraryIndexURL string = "http://downloads.arduino.cc/libraries/library_index.json"
37+
// libraryIndexURL is the URL where to get library index.
38+
libraryIndexURL string = "http://downloads.arduino.cc/libraries/library_index.json"
3939
)
4040

4141
// DownloadLibrariesFile downloads the lib file from arduino repository.
4242
func DownloadLibrariesFile() error {
43-
return common.DownloadPackageIndex(IndexPath, LibraryIndexURL)
43+
return common.DownloadPackageIndex(IndexPath, libraryIndexURL)
4444
}
4545

4646
// getDownloadCacheFolder gets the folder where temp installs are stored

0 commit comments

Comments
 (0)